Example #1
0
<?php

// Load Nette Framework or autoloader generated by Composer
require dirname(__FILE__) . '/../libs/autoload.php';
ini_set('error_reporting', 1);
$configurator = new NConfigurator();
// Enable Nette Debugger for error visualisation & logging
//if ($_SERVER['HTTP_HOST'] == 'gis.drino.net' || $_SERVER['HTTP_HOST']=='gymfed.drino.net') {
$configurator->setDebugMode(TRUE);
$configurator->addParameters(array("environment" => 'development'));
//}
$configurator->enableDebugger(dirname(__FILE__) . '/../log');
// Specify folder for cache
$configurator->setTempDirectory(dirname(__FILE__) . '/../temp');
// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()->addDirectory(dirname(__FILE__))->addDirectory(dirname(__FILE__) . '/../libs')->register();
// Create Dependency Injection container from config.neon file
$configurator->addConfig(dirname(__FILE__) . '/config/config.neon');
$configurator->addConfig(dirname(__FILE__) . '/config/config.local.neon', NConfigurator::NONE);
// none section
$container = $configurator->createContainer();
//////////////////
function dd($var, $name = null)
{
    return NDebugger::barDump($var, $name);
}
/////////////////
// Nastavi priznak NRoute::SECURED, pokud prichazime pres HTTPS
//NRoute::$defaultFlags |= ($container->getService('httpRequest')->isSecured() ? NRoute::SECURED : 0);
//    if(preg_match('~.*\.drino\.net~', $_SERVER['HTTP_HOST'])) $domena = "gymfed.drino.net";
//    else $domena = "www.gymfed.cz";
Example #2
0
	/**
	 * Loads global configuration from file and process it.
	 * @param  string
	 * @param  string
	 * @return NArrayHash
	 */
	public static function loadConfig($file = NULL, $section = NULL)
	{
		if (self::$createdAt) {
			throw new InvalidStateException('NConfigurator has already been created automatically by NEnvironment at ' . self::$createdAt);
		}
		$configurator = new NConfigurator;
		$configurator
			->setDebugMode(!self::isProduction())
			->setTempDirectory(defined('TEMP_DIR') ? TEMP_DIR : '');
		if ($file) {
			$configurator->addConfig($file, $section);
		}
		self::$context = $configurator->createContainer();

		self::$createdAt = '?';
		foreach (PHP_VERSION_ID < 50205 ? debug_backtrace() : debug_backtrace(FALSE) as $row) {
			if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], NETTE_DIR . DIRECTORY_SEPARATOR) !== 0) {
				self::$createdAt = "$row[file]:$row[line]";
				break;
			}
		}
		return self::getConfig();
	}