我想知道是否有可能在Symfony的的app.php中定义多环境
src/web/app.php:
$kernel = new AppKernel('benchmark', false);
$kernel = new AppKernel('benchmark,dev', false); // < Incl. the dev tools我为什么要问?这难道不是一个愚蠢的问题吗?,因为默认的检查语法似乎支持多个环境,in_array(),还是我在这里误解了什么?
src/app/AppKernel.php:
if (in_array($this->getEnvironment(), array('dev'))) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
...
}发布于 2013-12-06 16:35:00
app/AppKernel中的" check“是为了检查在一些环境中是否有您想要的包,例如"test”或"dev“。
然后,您可以在您的AppKernel中包含以下行:
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new My\Bundle\Uber\MyUberBundle();
...
}这将在dev和测试环境中启用此示例包。
因此,app.php不支持多个环境定义。如果需要多个env,仍然可以将新文件定义为app.php和app_dev.php :)
例如,带有自身的admin.php看起来如下所示
<?php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('admin', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);https://stackoverflow.com/questions/20428868
复制相似问题