diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index c037e0c3c29..286a4e530ae 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -2845,6 +2845,69 @@ Use the application logger instead of the PHP logger for logging PHP errors. When an integer value is used, it also sets the log level. Those integer values must be the same used in the `error_reporting PHP option`_. +This option also accepts a map of PHP errors to log levels: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/framework.yaml + framework: + php_errors: + log: + '!php/const \E_DEPRECATED': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_USER_DEPRECATED': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_NOTICE': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_USER_NOTICE': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_STRICT': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_WARNING': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_USER_WARNING': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_COMPILE_WARNING': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_CORE_WARNING': !php/const Psr\Log\LogLevel::ERROR + '!php/const \E_USER_ERROR': !php/const Psr\Log\LogLevel::CRITICAL + '!php/const \E_RECOVERABLE_ERROR': !php/const Psr\Log\LogLevel::CRITICAL + '!php/const \E_COMPILE_ERROR': !php/const Psr\Log\LogLevel::CRITICAL + '!php/const \E_PARSE': !php/const Psr\Log\LogLevel::CRITICAL + '!php/const \E_ERROR': !php/const Psr\Log\LogLevel::CRITICAL + '!php/const \E_CORE_ERROR': !php/const Psr\Log\LogLevel::CRITICAL + + .. code-block:: xml + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/framework.php + use Psr\Log\LogLevel; + use Symfony\Config\FrameworkConfig; + + return static function (FrameworkConfig $framework) { + $framework->phpErrors()->log(\E_DEPRECATED, LogLevel::ERROR); + $framework->phpErrors()->log(\E_USER_DEPRECATED, LogLevel::ERROR); + // ... + }; + +.. versionadded:: 5.3 + + The option to map PHP errors to log levels was introduced in Symfony 5.3. + throw .....