3

I would like all errors (notices, etc) to be treated as exceptions in Symfony 3.4 and to halt the application.

This is the same for PHP as "use strict" in JavaScript.

Edit:

When using debug true when creating an AppKernel it enables strict mode.

However this is not what I want. This mode is for production, not for debugging and debugging should not be enabled in production so the question is how to enable it without enabling debug.

jgmjgm
  • 4,240
  • 1
  • 25
  • 18

2 Answers2

1

This can be done with the parameter "debug.error_handler.throw_at".

For example:

parameters:
  debug.error_handler.throw_at: 32767

E_ALL => 32767

Some debug infrastructure is loaded regardless of if the framework is in production mode or otherwise as the debug libraries are tightly coupled with the framework. Most of the framework's core error handling resides within the debug package.

jgmjgm
  • 4,240
  • 1
  • 25
  • 18
0

If you can upgrade php, just use a php version that consider error as exception:

http://php.net/manual/en/class.errorexception.php

and manage error handling with a custom listener (for example):

sensorario
  • 20,262
  • 30
  • 97
  • 159
  • This is for symfony. For PHP it's very trivial but not symfony which reimplements error handling. – jgmjgm Apr 04 '18 at 10:43