没有为在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
哪些是更好的解决方案。
不需要这么长的onBoostrap代码。他可以将error_reporting放在配置文件本身中,因为它是一个PHP文件。 – akond 2013-03-10 14:50:02
@akond +1你是非常正确的,这是一个更好的选择,引导程序代码只是为了演示如何使OP工作。 – Crisp 2013-03-10 14:54:24
这有帮助,谢谢:) – 2013-03-14 05:40:08