Is it possible to have PHP stop execution upon a notice/warning, globally?
We run a development server with a lot of sites on, but want to force our developers to fi
You can globally configure this within your php.ini fileDocs.
You do this by specifying a file that is being included by all PHP processes with the auto_prepend_file directiveDocs:
auto_prepend_file "/full/path/to/a/prepend-file.php"
Doing that inside you global php.ini file will ensure that the code inside the prepend file will be always exectued. You can use it then to register a global error handler that will turn all errors into exceptionsDocs:
This little script will turn all errors/warnings/notices etc. into an ErrorException.
Combine it with the error_reporting ini directiveDocs, the values are describe in your php.ini file.
Throwing an exception is a very strict thing. Your programmers will be forced to deal with warnings and errors otherwise the code won't not work.
Probably this is too much for your programmers and not socially acceptable within your company. Instead you can also log all errors and add them at the end of the output (or at the top so it's more visible) by making use of output buffering.
Another alternative is to log errors and warnings to the logfile and then monitor that file with another process and aggregate the information. You could create a scoreboard that display the number of warnings per application and make this visible in the office so everybody sees how well a team performs or some fun like that.
What I try to say is: Next to the technical problem, it's a social problem you need to be creative with and actually talk the problem out of your developers. You need to make clear why it's important to fix warnings and errors and how their coding and skills will benefit from that.