Welcome Guest, Not a member yet? Register   Sign In
Fatal Error When Set CI_DEBUG to False On Production Mode Codeigniter 4
#1

Why I get this error when set from Config/Boot/production.php CI_DEBUG to false in production mode ? this is the default setting from CI4.

Code:
defined('CI_DEBUG') || define('CI_DEBUG', false);

Code:
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

For Development And Testing Mode run without problem. This error just occur when using routes->resource (RESTFUL API).

It is not clear what error is this. I try to replace the system folder with new one. But the error still exists.

It is said "Uncaught Error: Class "CodeIgniter\Log\Logger" not found" I don't know what is the problem with this and why it is not found.

Now my app just run with set CI_DEBUG to true to prevent the error. But the default is set to false for production.

defined('CI_DEBUG') || define('CI_DEBUG', true);

What is missing in here ? It is so strange that setting the CI_ENVIRONMENT to development or testing worked without a problem. But for production not working. So I decide to turn on the error display in production mode and found the error above. 

Seriously need help.
Reply
#2

I found the problem in the restful api.

The problem is in the config/filter.php


Code:
$routes->resource('ApiManageTips', ['controller' =>'App\Controllers\ApiData\ApiManageTips']); // get, put, create, delete



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



The Above example is working in the version 4.1.2  but is not working in version 4.2.6

Instead change to :

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



I don't why it is not working in the CI Version 4.2.6.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB