Codeigniter 4.0.4部署在共享托管错误

时间:2020-09-05 11:31:09

标签: codeigniter

我试图在共享托管cpanel上部署我的codeigniter 4应用程序。

我已经按照互联网上的教程进行学习了。

我得到了错误:

致命错误:未捕获错误:调用未定义函数 CodeIgniter \ locale_set_default()在 /home/myhost/server_ci4/system/CodeIgniter.php:184堆栈跟踪:#0 /home/myhost/server_ci4/system/bootstrap.php(181): CodeIgniter \ CodeIgniter-> initialize()#1 /home/myhost/public_html/ci4/index.php(36): require('/ home / myhost / ...')#2 {main}被抛出 /home/myhost/server_ci4/system/CodeIgniter.php,第184行

我不明白该错误,该如何解决?这样就可以很好地运行

1 个答案:

答案 0 :(得分:0)

最后,我发现它是codeigniter v 4.0.4的一个错误。

解决方法是:

打开:/system/Codeigniter.php

第181行:public function initialize()将功能更新为:

/**
     * Handles some basic app and environment setup.
     */
    public function initialize()
    {
        // Set default locale on the server
        if( function_exists('locale_set_default' ) ) :
            locale_set_default($this->config->defaultLocale ?? 'en');
        endif; 

        // Set default timezone on the server
        date_default_timezone_set($this->config->appTimezone ?? 'UTC');

        // Define environment variables
        $this->detectEnvironment();
        $this->bootstrapEnvironment();

        // Setup Exception Handling
        Services::exceptions()
                ->initialize();

        $this->initializeKint();

        if (! CI_DEBUG)
        {
            // @codeCoverageIgnoreStart
            \Kint::$enabled_mode = false;
            // @codeCoverageIgnoreEnd
        }
    }

解决方案:

        if( function_exists('locale_set_default' ) ) :
            locale_set_default($this->config->defaultLocale ?? 'en');
        endif;