每次我在 Zend Framework 2 中收到错误时,我只会显示 500 Internal Server Error,并且必须搜索 Zend Server 错误日志。
我尝试将其放入我的 config/autoload/local.php 文件中,但它不起作用:
return array(
'phpSettings' => array(
'display_startup_errors' => true,
'display_errors' => true,
),
);
zf2 中没有对此的本机支持(据我所知)。您要么必须在 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
这是一个更好的解决方案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)