How do I turn on the PHP error reporting in Zend Framework 2?
frameworks, php, zend-framework2
Solution
There is no native support for that in zf2 (afaik). You'd either have to set them in php.ini itself, or set them in index.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
If you really want to be able to supply them as config settings, you could keep what you have and do that in a module bootstrap, get them from config, and call ini_set() on each key value pair
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);
}
}
}
Edit: as @akond rightly points out in the comments, you could just add the ini_set lines to `local.php` which is a better solution.
Problem
Everytime I receive an error in Zend Framework 2, I get just 500 Internal Server Error displayed and have to search through the Zend Server error log. I've tried putting this to my config/autoload/local.php file but it doesn't work: ``` return array( 'phpSettings' => array( 'display_startup_errors' => true, 'display_errors' => true, ), ); ```