We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt engine suppresses errors

I created "Hello World" by phalcon create-project example-project --enable-webtools and modified controller a bit:

    public function indexAction()
    {
        fopen('gregregerg');
    }

I should see "Warning: fopen() expects at least 2 parameters..." but nothing happens. Do I have to put exit each time to ensure, that code is ok?



43.9k

Hi,

do you have already an oppened terminal with

tail -f /var/log/apache2/error.log

command running in it ? There you will find all php errors and warning you want.

eg:

PHP Warning: Invalid argument supplied for foreach() in /var/www/html/phalcon/custom/test

PHP Fatal error: 'continue' not in the 'loop' or 'switch' context in /var/www/html/phalcon/custom/test4/app/controllers/FileController.php on line 49, referer: https://localhost/phalcon/custom/test4/file/index



8.3k

Thx for quick reply.

There you will find all php errors and warning you want.

I know and it works correctly, but it's inconvenience. I think it's widely common in dev mode see all warnings, notices etc. immediately. P.S. -> I've checked also sample error and it appears on screen, so it seems that volt has own error settings, independent on app settings, what doesn't sound good to me.



43.9k
Accepted
answer
edited Jan '18

you can use the debug component https://docs.phalcon.io/en/3.2/api/Phalcon_Debug like this in index.php:


$debug = new \Phalcon\Debug();
$debug->listenLowSeverity(); // here you will get low level warnings

don't forget to remove all the try catch statements in index.php



8.3k

I've just tested and it seems to work, thx for advice.

le51, great answer! Havnt notice this so far :)

Thanks to you I've modified my bootstrap file, sharing, in case someone finds it useful:

try {
    $root = str_replace('\\', '/', dirname(dirname(__FILE__))) . '/';
    require_once $root . 'apps/Bootstrap.php';
    $bootstrap = new Bootstrap();

    // Listen for all notices, warnings and exceptions in Dev mode
    if ($bootstrap->getApp()->config->debug === true) {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);

        $debug = new \Phalcon\Debug();
        $debug->listenLowSeverity();
    } else {
        error_reporting(0);
    }

    // Run
    $bootstrap->run();
} catch (\Exception $e) {
    if ($bootstrap->getApp()->config->debug === true) {
        $debug = new \Phalcon\Debug();
        die($debug->listen()->onUncaughtException($e));
    } else {
        header('HTTP/1.1 500 Internal Server Error');
        // Show error 500 page
    }
}

P.S. Michal, you can accept le51's answer :)