本文整理汇总了PHP中Configurator::createContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Configurator::createContainer方法的具体用法?PHP Configurator::createContainer怎么用?PHP Configurator::createContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configurator
的用法示例。
在下文中一共展示了Configurator::createContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: barDump
$configurator->enableDebugger(APP_DIR . '/log');
function barDump($x)
{
Debugger::barDump($x);
}
// Enable RobotLoader - this will load all classes automatically
$configurator->setTempDirectory(APP_DIR . '/temp');
$configurator->createRobotLoader()->addDirectory(APP_DIR)->addDirectory(LIBS_DIR)->register();
// Create Dependency Injection container from config.neon files
$configurator->addConfig(LIBS_DIR . '/npress/config.neon');
$configurator->addConfig(APP_DIR . '/config.neon');
$configurator->addConfig(WWW_DIR . '/data/config.neon');
if (file_exists(WWW_DIR . '/data/config.local.neon')) {
$configurator->addConfig(WWW_DIR . '/data/config.local.neon');
}
$container = $configurator->createContainer();
// Connect to the database
dibi::connect($container->params['database']);
// Setup router
$container->router[] = $adminRouter = new RouteList('Admin');
$adminRouter[] = new Route('admin/<presenter>/<action>[/<id_page>]', 'Admin:default', isset($_SERVER['HTTPS']) ? Route::SECURED : false);
$container->router[] = $frontRouter = new RouteList('Front');
$frontRouter[] = new Route('data/thumbs/<id>[.<opts>].png', 'Files:preview');
$frontRouter[] = new Route('files[/<action>][/<id>]', 'Files:default');
$frontRouter[] = new Route('index.php', 'Pages:default', Route::ONE_WAY);
$frontRouter[] = new PagesRouter();
$frontRouter[] = new RedirectRouter();
$frontRouter[] = new Route('<presenter>[/<action>]/<id_page>', array('presenter' => 'Pages', 'action' => 'default', 'id_page' => 1));
// Include app specific bootstrap.php
if (file_exists(APP_DIR . '/bootstrap.php')) {
require_once APP_DIR . '/bootstrap.php';
示例2: loadConfig
/**
* Loads global configuration from file and process it.
* @param string
* @param string
* @return ArrayHash
*/
public static function loadConfig($file = NULL, $section = NULL)
{
if (self::$createdAt) {
throw new InvalidStateException('Configurator has already been created automatically by Environment at ' . self::$createdAt);
}
$configurator = new Configurator();
$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();
}