Example #1
0
/**
 * My Application bootstrap file.
 */
// Load Nette Framework
require LIBS_DIR . '/Nette/loader.php';
// Enable Nette Debugger for error visualisation & logging
NDebugger::$logDirectory = dirname(__FILE__) . '/../log';
NDebugger::$strictMode = TRUE;
NDebugger::enable();
// Configure application
$configurator = new NConfigurator();
$configurator->setTempDirectory(dirname(__FILE__) . '/../temp');
// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()->addDirectory(APP_DIR)->addDirectory(LIBS_DIR)->register();
// Create Dependency Injection container from config.neon file
$configurator->addConfig(dirname(__FILE__) . '/config/config.neon');
$container = $configurator->createContainer();
// Opens already started session
if ($container->session->exists()) {
    $container->session->start();
}
// Setup router
$router = $container->router;
$router[] = new NRoute('index.php', 'Dashboard:default', NRoute::ONE_WAY);
$router[] = new NRoute('<presenter>/<action>[/<id>]', 'Dashboard:default');
// Configure and run the application!
$application = $container->application;
//$application->catchExceptions = TRUE;
$application->errorPresenter = 'Error';
$application->run();
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
			->setProductionMode(self::isProduction())
			->setTempDirectory(defined('TEMP_DIR') ? TEMP_DIR : '');
		if ($file) {
			$configurator->addConfig($file, $section);
		}
		self::$context = $configurator->createContainer();

		self::$createdAt = '?';
		foreach (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();
	}