zf2 (afaik) 中没有对它的本机支持。您要么必须在 php.ini 本身中设置它们,要么在 index.php 中设置它们
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
如果您真的希望能够将它们作为配置设置提供,您可以保留您所拥有的并在模块引导程序中执行此操作,从配置中获取它们,然后在每个键值对上调用 ini_set()
public function onBootstrap(EventInterface $e) {
$app = $e->getApplication();
$sm = $app->getServiceManager();
$config = $sm->get('Config');
$phpSettings = isset($config['phpSettings']) ? $config['phpSettings'] : array();
if(!empty($phpSettings)) {
foreach($phpSettings as $key => $value) {
ini_set($key, $value);
}
}
}
编辑:正如@akond 在评论中正确指出的那样,您可以添加 ini_set 行,local.php
这是一个更好的解决方案。