0

如果我编写了一些带有弃用通知的 PHP 代码,它会显示在本地环境中。

示例:index.php

<?php

function super(string $test='', string $essai)
{
    return 'toto';
}

super('sy', 1);

exit;

显示:

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

这很好。

但是 Laravel 控制器中完全相同的代码不会显示,也不会存储在任何日志文件中。我将配置 app.env 设置为“local”,将 app.debug 设置为 true,将 app.log_level 设置为“debug”。知道我缺少什么吗?

4

1 回答 1

0

根据文档

记录弃用警告

PHP、Laravel 和其他库经常通知他们的用户,他们的一些功能已被弃用,并将在未来的版本中删除。如果您想记录这些弃用警告,您可以deprecations在应用程序的config/logging.php配置文件中指定首选日志通道:

'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),

'channels' => [
    ...
]

或者,您可以定义一个名为 deprecations 的日志通道。如果存在具有此名称的日志通道,它将始终用于记录弃用:

'channels' => [
    'deprecations' => [
        'driver' => 'single',
        'path' => storage_path('logs/php-deprecation-warnings.log'),
    ],
],
于 2022-01-26T15:11:46.867 回答