在生产模式Codeigniter 4上将CI_DEBUG设置为False时出现致命错误

qcuzuvrc  于 2022-12-06  发布在  其他
关注(0)|答案(1)|浏览(133)

为什么在生产模式下将Config/ Boot /production.php****CI_DEBUG设置为false时会出现此错误?这是CI 4的默认设置。
定义的('CI_DEBUG')||配置项调试器

Fatal error: Declaration of CodeIgniter\Log\Logger::emergency($message, array $context = []): bool must be compatible with Psr\Log\LoggerInterface::emergency(Stringable|string $message, array $context = []): void in E:\testing\Source Code\testing_CI_v.4.2.6\system\Log\Logger.php on line 157

Fatal error: Uncaught Error: Class "CodeIgniter\Log\Logger" not found in E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\Services.php:391 Stack trace: #0 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\BaseService.php(253): CodeIgniter\Config\Services::logger(false) #1 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\BaseService.php(194): CodeIgniter\Config\BaseService::__callStatic('logger', Array) #2 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\Services.php(388): CodeIgniter\Config\BaseService::getSharedInstance('logger') #3 E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\BaseService.php(253): CodeIgniter\Config\Services::logger(true) #4 E:\testing\Source Code\testing_CI_v.4.2.6\system\Common.php(799): CodeIgniter\Config\BaseService::__callStatic('logger', Array) #5 E:\testing\Source Code\testing_CI_v.4.2.6\system\Debug\Exceptions.php(114): log_message('critical', '{message}\nin {e...', Array) #6 E:\testing\Source Code\testing_CI_v.4.2.6\system\Debug\Exceptions.php(180): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #7 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #8 {main} thrown in E:\testing\Source Code\testing_CI_v.4.2.6\system\Config\Services.php on line 391

对于开发和测试模式运行没有问题。这个错误只是在使用路由-〉资源(RESTFUL API)时发生。
不清楚是什么错误,我试着用新文件夹替换系统文件夹,但错误仍然存在。
显示**“未捕获的错误:类“CodeIgniter\Log\Logger”未找到”我不知道这是什么问题,为什么找不到它。
现在,我的应用程序只需
将CI_DEBUG设置为true以防止错误。但默认设置为false用于生产。**
定义的('CI_DEBUG')||配置项调试器
这里缺少了什么?很奇怪,将CI_ENVIRONMENT设置为开发或测试时没有问题。但对于生产模式则不起作用。因此,我决定在生产模式下打开错误显示,并发现了上述错误。
我真的需要帮助。

bxfogqkk

bxfogqkk1#

我在restful api中发现了问题。
问题出在config/filter.php文件中
第一个
上述示例在版本4.1.2中有效,但在版本4.2.6中无效

改为:

public $filters = [                           
        'basicauth'    => ['before' =>
                                [                              
                                    'ApiManageTips/*',                                   
                                ]
        ];

我不知道为什么它在CI版本4.2.6中不起作用。

相关问题