예제 #1
0
/**
 * My Application bootstrap file.
 *
 * @copyright  Copyright (c) 2009 John Doe
 * @package    MyApplication
 */
// Step 1: Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
require __DIR__ . '/../../vendor/autoload.php';
// Step 2: Configure environment
// 2a) enable Nette\Debug for better exception and error visualisation
\Nette\Diagnostics\Debugger::enable(\Nette\Diagnostics\Debugger::DEVELOPMENT, APP_DIR . "/log");
// 2b) load configuration from config.ini file
//Nette\Environment::loadConfig();
// Step 3: Configure application
// 3a) get and setup a front controller
$application = Nette\Environment::getApplication();
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
$loader = new \Nette\Loaders\RobotLoader();
$loader->setCacheStorage(Nette\Environment::getContext()->cacheStorage);
$loader->addDirectory(APP_DIR);
$loader->register();
use Nette\Application\Routers\Route;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new Route('index.php', array('presenter' => 'Download', 'action' => 'default'), Route::ONE_WAY);
$router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Download', 'action' => 'default', 'id' => NULL));
// Step 5: Run the application!
$application->run();
예제 #2
0
파일: index.php 프로젝트: Ginny/examples
// Nette Framework Microblog example

use Nette\Diagnostics\Debugger;


// load libraries
require __DIR__ . '/../../../Nette/loader.php';
require __DIR__ . '/data/TemplateRouter.php';


// enable Debugger
Debugger::$logDirectory = __DIR__ . '/data/log';
Debugger::$strictMode = TRUE;
Debugger::enable();


// enable template router
$context = Nette\Environment::getContext();
$context->params['tempDir'] = __DIR__ . '/data/temp';
$context->application->router[] = new TemplateRouter('data/templates');


// add access to database
$context->addService('database', function() {
	return new Nette\Database\Connection('sqlite2:data/blog.sdb');
});


// run the application!
$context->application->run();