public function loadNeon($neonFile) { if (!is_file($neonFile)) { throw new \Nette\Application\ApplicationException(sprintf("Environment configuration file '%s' not found.", $neonFile)); } $this->data = Nette\Neon\Neon::decode(file_get_contents($neonFile)); }
try { $latte = new Latte\Engine(); $latte->setLoader(new Latte\Loaders\StringLoader()); $latte->compile($s); } catch (Latte\CompileException $e) { if (!preg_match('#Unknown (macro|attribute)#A', $e->getMessage())) { $checker->error($e->getMessage(), $e->sourceLine); } } } }; // lint Neon $checker->tasks[] = function (CodeChecker $checker, $s) { if ($checker->is('neon')) { try { Nette\Neon\Neon::decode($s); } catch (Nette\Neon\Exception $e) { $checker->error($e->getMessage()); } } }; // white-space remover $checker->tasks[] = function (CodeChecker $checker, $s) { $new = Strings::replace($s, '#[\\t ]+(\\r?\\n)#', '$1'); // right trim $eol = preg_match('#\\r?\\n#', $new, $m) ? $m[0] : PHP_EOL; $new = rtrim($new); // trailing trim if ($new !== '') { $new .= $eol; }
* @package IRCBot * @author Super3 <*****@*****.**> * @author Matej Velikonja <*****@*****.**> */ define('ROOT_DIR', __DIR__); define('CONFIG_FILE', '/config.neon'); // Configure PHP //ini_set( 'display_errors', 'on' ); // Make autoload working require 'Classes/Autoloader.php'; spl_autoload_register('Autoloader::load'); if (!file_exists(ROOT_DIR . CONFIG_FILE) || ($config = file_get_contents(ROOT_DIR . CONFIG_FILE)) === false) { die('Could not read config file. Please Look at the Installaion Documentation.' . PHP_EOL); } try { $config = Nette\Neon\Neon::decode($config); } catch (Nette\Neon\Exception $e) { die('Configuration syntax error: ' . $e->getMessage() . PHP_EOL); } $timezone = ini_get('date.timezone'); if (empty($timezone)) { if (empty($config['timezone'])) { $config['timezone'] = 'UTC'; } date_default_timezone_set($config['timezone']); } // Initialise the LogManager. $log = new Library\IRC\Log($config['log']); // Create the bot. $bot = new Library\IRC\Bot($config, $log); // Register the shutdown function.
<?php $configurator = new Nette\Configurator(); // Uncomment following line to enable dynamic debug mode // $debugModeConfig = __DIR__ . '/config/debugger.neon'; if (isset($debugModeConfig)) { $ips = Nette\Neon\Neon::decode(file_get_contents($debugModeConfig)); if (!empty($ips)) { $configurator->setDebugMode($ips); } } $configurator->enableDebugger(__DIR__ . '/../log'); $configurator->setTempDirectory(__DIR__ . '/../temp'); // Uncomment following line to enable workbench support // $workbenchActive = TRUE; if (isset($workbenchActive)) { $configurator->createRobotLoader()->addDirectory(__DIR__ . '/../workbench')->register(); } $configurator->addConfig(__DIR__ . '/config/config.neon'); $container = $configurator->createContainer(); return $container;
<?php require __DIR__ . '/vendor/autoload.php'; $localConfig = Nette\Neon\Neon::decode(file_get_contents(__DIR__ . '/app/config/config.local.neon')); $dsn = $localConfig['database']['dsn']; $dsnArray = explode(';dbname=', $dsn); $dsnHost = explode(':host=', $dsnArray[0]); $dsnDb = $dsnArray[1]; $adapter = $dsnHost[0]; $host = $dsnHost[1]; $database = $dsnDb; $user = $localConfig['database']['user']; $password = $localConfig['database']['password']; return ['paths' => ['migrations' => 'app/migrations'], 'environments' => ["default_migration_table" => "_phinx_log", "default_database" => "production", "production" => array("adapter" => $adapter, "host" => $host, "name" => $database, "user" => $user, "pass" => $password)]];
<?php $filenames = ['post_types', 'settings', 'taxonomies', 'meta_fields']; if (!defined('NEON_WP_DIR')) { define('NEON_WP_DIR', __DIR__ . '/..'); } add_theme_support('post-thumbnails'); $alternate_posts_per_page = array(); foreach ($filenames as $filename) { $path = NEON_WP_DIR . "/{$filename}.neon"; if (!file_exists($path)) { continue; } $str = file_get_contents($path); $res = Nette\Neon\Neon::decode($str); $defaults = empty($res['defaults']) ? [] : $res['defaults']; $register = $res['register']; foreach ($register as $name => $data) { if (is_string($data)) { $data = ['label' => $data]; } if (empty($data['name']) && is_string($name)) { $data['name'] = $name; } $data = $data + $defaults; if (!empty($data['menu_icon']) && substr($data['menu_icon'], 0, 9) !== 'dashicons') { $data['menu_icon'] = 'dashicons-' . $data['menu_icon']; } if ($filename === 'post_types') { register_post_type($data['name'], $data); if (isset($data['per_page'])) {