简体   繁体   中英

Disable exit() on strict errors in Laravel

I have a Laravel application that has to integrate with a legacy external code base. I spent weeks making sure that everything worked. Unfortunately I'm not the only developer, and as the other code base doesn't exit on strict errors, they don't get fixed, or caught, until it breaks my code. And I only find out afterwards.

I need to disable exit() on strict errors. Fatal errors should still fail. A cursory google search only returns "Don't" which is obviously the best option, but unfortunately not possible in my circumstances.

Add error_reporting line right after application initialization to bootstrap/app.php as follow:

$app = new Illuminate\Foundation\Application(
    // Laravel\Lumen\Application in case of Lumen
    realpath(__DIR__.'/../')
);
error_reporting(E_ALL & ~E_STRICT);

This will prevent ErrorException to be thrown on E_STRICT . Same applies for Lumen :

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);
error_reporting(E_ALL & ~E_STRICT);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM