'How to display warning and deprecated messages in Laravel
If I write some PHP code with a deprecated notice, it displays on a local environment.
Example: index.php
<?php
function super(string $test='', string $essai)
{
return 'toto';
}
super('sy', 1);
exit;
Displays:
Deprecated: Optional parameter $test declared before required parameter $essai is implicitly treated as a required parameter in /var/www/public/index.php on line 9
Which is fine.
But the exact same code in a controller in Laravel does not display, and is not stored in any log file. I set the config app.env to "local", app.debug to true and app.log_level to "debug". Any idea what I am missing ?
Solution 1:[1]
According to the docs:
Logging Deprecation Warnings
PHP, Laravel, and other libraries often notify their users that some of their features have been deprecated and will be removed in a future version. If you would like to log these deprecation warnings, you may specify your preferred
deprecationslog channel in your application'sconfig/logging.phpconfiguration file:'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 'channels' => [ ... ]Or, you may define a log channel named deprecations. If a log channel with this name exists, it will always be used to log deprecations:
'channels' => [ 'deprecations' => [ 'driver' => 'single', 'path' => storage_path('logs/php-deprecation-warnings.log'), ], ],
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kenny Horna |
