Search code examples
codeigniterxamppcodeigniter-4

Call to undefined function CodeIgniter\locale_set_default() - Xampp


I'm trying to set up Codeigniter4 with Xampp but when calling the public address http://localhost/projectfolder/public/index.php as stated in the README.md file of the CodeIgniter4 framework, the next error appears:

<br />
<b>Fatal error</b>: Uncaught Error: Call to undefined function CodeIgniter\locale_set_default() in
C:\xampp\htdocs\codeigniter4\system\CodeIgniter.php:184
Stack trace:
#0 C:\xampp\htdocs\codeigniter4\system\bootstrap.php(181): CodeIgniter\CodeIgniter-&gt;initialize()
#1 C:\xampp\htdocs\codeigniter4\public\index.php(36): require('C:\\xampp\\htdocs...')
#2 {main}
thrown in <b>C:\xampp\htdocs\codeigniter4\system\CodeIgniter.php</b> on line <b>184</b><br />

I've tried this solution but it didn't work for me.

Does anybody know how to solve it?


Solution

  • I found my temporary solution in here, without updating de PHP Version in Xampp.

    Go to C:\xampp\htdocs\projectfolder\system\CodeIgniter.php - line 184 and change the next line.

    Before:

    locale_set_default($this->config->defaultLocale ?? 'en');
    

    After:

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

    Once I updated Xampp to the 7.4 version (download here), I just needed to enable the extension=intl in the xampp\php\php.ini file. As it is explained here, you just have to uncomment the line from ;extension=intl to extension=intl.

    Then you can leave the C:\xampp\htdocs\projectfolder\system\CodeIgniter.php - line 184 as it was in the beginning.

    locale_set_default($this->config->defaultLocale ?? 'en');