11

我在 Symfony2 配置文件中找到了一些预定义的参数,即。%kernel.root_dir%, %kernel.debug%.

  • 在某处是否有这些的完整列表?
4

2 回答 2

16

他们在下面Symfony\Component\HttpKernel\Kernel.php

/**
 * Returns the kernel parameters.
 *
 * @return array An array of kernel parameters
 */
protected function getKernelParameters()
{
    $bundles = array();
    foreach ($this->bundles as $name => $bundle) {
        $bundles[$name] = get_class($bundle);
    }

    return array_merge(
        array(
            'kernel.root_dir'        => $this->rootDir,
            'kernel.environment'     => $this->environment,
            'kernel.debug'           => $this->debug,
            'kernel.name'            => $this->name,
            'kernel.cache_dir'       => $this->getCacheDir(),
            'kernel.logs_dir'        => $this->getLogDir(),
            'kernel.bundles'         => $bundles,
            'kernel.charset'         => $this->getCharset(),
            'kernel.container_class' => $this->getContainerClass(),
        ),
        $this->getEnvParameters()
    );
}
于 2013-10-12T14:50:28.010 回答
0

您还可以在app/cache/dev/appDevDebugProjectContainer.php:getDefaultParameters()(位于文件末尾)中看到它们,以及您的应用程序可用的所有其他参数。

/**
 * Gets the default parameters.
 *
 * @return array An array of the default parameters
 */
protected function getDefaultParameters()
{
    return array(
        'kernel.root_dir' => $this->targetDirs[2],
        'kernel.environment' => 'dev',
        'kernel.debug' => true,
        'kernel.name' => 'app',
        'kernel.cache_dir' => __DIR__,
        'kernel.logs_dir' => ($this->targetDirs[2].'/logs'),
        ...
    );
}
于 2015-08-07T16:55:04.623 回答