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,
),
);
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.
To easilly configure phpSettings on your ZF2 app, you should consider using DluPhpSettings.
With this module, you can configure your settings for each environment you have:
/* Local application configuration in /config/autoload/phpsettings.local.php */
<?php
return array(
'phpSettings' => array(
'display_startup_errors' => false,
'display_errors' => false,
'max_execution_time' => 60,
'date.timezone' => 'Europe/Prague',
'mbstring.internal_encoding' => 'UTF-8',
),
);
Look this blog post for more info too!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With