970_90

Monday, 28 December 2015

How to enable error reporting in Zend Framework 2?

How to enable error reporting in Zend Framework 2?

Question: How to enable error reporting in Zend Framework 2?
Open index.php in public folder.
and add following line at the top.
error_reporting(E_ALL);
ini_set("display_errors", 1);



Question: How to enable error reporting in Zend Framework 2 for Development Server only?
Set the different APPLICATION_ENV value for development and production with use of .htaccess. For Example

Add following in .htaccess file in Development Server
SetEnv APPLICATION_ENV development

Add following in .htaccess file in Production Server
SetEnv APPLICATION_ENV production


Add following line in top of public/index.php
 if ($_SERVER['APPLICATION_ENV'] == 'development') {
     error_reporting(E_ALL);
     ini_set("display_errors", 1);
 }else if($_SERVER['APPLICATION_ENV'] == 'production'){
     error_reporting(0);
     ini_set("display_errors", 0);
}



No comments:

Post a Comment