在 Zend 框架 3 中设置 APPLICATION_ENV

Set APPLICATION_ENV in Zend framework 3

我已经使用 composer development-enable 启用了开发模式。我如何检查模块的 config/module.config.php 开发是否已启用?

我还在 public/.htaccess 中添加了 SetEnv APPLICATION_ENV development 并尝试使用 echo APPLICATION_ENV;exit;module.config.php 中使用它,但它没有给我环境。

如何在 zend framework 3 中设置和获取应用程序环境?

使用 correct function ;)

$environment = getenv('APPLICATION_ENV');

ZF2/3 中配置的用法:

$env = getenv('APPLICATION_ENV'); // Expect null or "development"

$modules = [];

if ($env === 'development') {
    //Array of modules used only for development
    $modules = array_merge_recursive($modules, [
        'Zf2Whoops',
    ]);
}

在 Zend Framework 中,使用 composer development-enable 没有什么特别之处。但是,如果您在某个时候使用 Apigility,它会为您创建一个 development.config.php 文件来禁用应用程序缓存。