I implemented this solution:
Only you have to modify file index.php in public folder and set:
- Set error_reporting with value 0.
- In catch block, Comment or Delete echo code.
- If you want, could redirect to a specific controller and view and so not show blank page or default error 500 in browser
This is a example of my index.php file:
use Phalcon\Di\FactoryDefault;
use Phalcon\Http\Response; // Use Namespace to allow redirect
error_reporting(0); // Production // E_ALL Value to Development Enviroment
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . '/app');
try {
/**
* The FactoryDefault Dependency Injector automatically registers
* the services that provide a full stack framework.
*/
$di = new FactoryDefault();
/**
* Read services
*/
include APP_PATH . "/config/services.php";
/**
* Get config service for use in inline setup below
*/
$config = $di->getConfig();
/**
* Include Autoloader
*/
include APP_PATH . '/config/loader.php';
/**
* Handle the request
*/
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
} catch (\Exception $e) {
// *********** Production Enviroment ******************
// Disable phalcon errors...
// you could comment or delete...
//echo $e->getMessage() . '<br>';
//echo '<pre>' . $e->getTraceAsString() . '</pre>';
// If you want, redirect to a specific view
$response = new Response();
// Redirect...
$response->redirect('error/show500'); // I have a Controller called error and a view with styles to show error 500
// Send response to the client
$response->send();
}