How to automatically handle all unhandled php errors in symfony2?-Collection of common programming errors
Disclaimer:
seems like you guys need some real world example for that. So here it is:
file_get_contents($filename);
Keep in mind about thread safety and race conditions.
or any other php notice/warning or any kind of recoverable exception.
where either is not defined. And run it in the default app.php
with all the default symfony v2.3.5 configs – I see
Notice: Undefined variable: i in /var/www/.../UIBundle/Controller/DeployController.php on line 57
Call Stack:
0.0000 629696 1. {main}() /var/www/.../web/app.php:0
Which is not what I expect since in the production mode framework should handle everything, log and show a nice 404/500 to a user.
What am I missing and what config parameter should change the behaviour to what I expect?
UPD:
this question is about how to handle unhandled php errors so that user didn’t see the stacktrace but a proper error page on production. So treat $i++
and \bla()
as some unexpected case, a bug.
UPD 2:
yes, I’m aware of the debug
parameter of the Kernel
class, and personally I don’t see switching to
$kernel = new AppKernel('prod', true);
^--- changed from false
reasonable, since I need a real production environment.
UPD 3:
Guys, I’m aware what unit, functional, acceptance and integration tests are for. The question IS NOT about testing. The question is: how to handle php errors by symfony2 natively.
UPD 4:
The question is about the latest symfony2 branch – 2.3 (or v2.3.5 specifically)
UPD 5:
Debug::enable(null, false);
– could please someone comment a possible negative side effects if I used this in production? — it doesn’t log notices/warnings :-S
Originally posted 2013-11-27 05:07:44.