Call to undefined function CodeIgniter\locale_set_default() - Xampp
Asked Answered
L

4

5

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?

Lucielucien answered 11/3, 2022 at 7:15 Comment(1)
Please follow this solution here. I answer this question enter link description hereAlar
L
1

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');
Lucielucien answered 11/3, 2022 at 7:15 Comment(2)
Disabling the use of one function in the framework doesn't solve the fundamental issue.Riyadh
You are right Steven. I didn't notice one of my desktops were still working in an old version of Xampp and also with an old version of PHP. Thanks!Lucielucien
R
7

The root of the issue is that you have a missing PHP extension. In particular:

Keep in mind that this is clearly stated in the frameworks' repository README.md file.

Server Requirements

PHP version 7.4 or higher is required, with the following extensions installed:

Additionally, make sure that the following extensions are enabled in your PHP:

  • json (enabled by default - don't turn it off)
  • xml (enabled by default - don't turn it off)
  • mysqlnd

In addition, it's also pointed out here:

Bug: Missing function locale_set_default(...) #3171

Please install intl extension - this is a required component.

Riyadh answered 11/3, 2022 at 8:3 Comment(0)
L
1

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');
Lucielucien answered 11/3, 2022 at 7:15 Comment(2)
Disabling the use of one function in the framework doesn't solve the fundamental issue.Riyadh
You are right Steven. I didn't notice one of my desktops were still working in an old version of Xampp and also with an old version of PHP. Thanks!Lucielucien
K
0

Install it via linux

sudo apt-get install php-intl

or for a PHP Version

sudo apt install php7.4-intl 
Kendalkendall answered 1/1, 2023 at 22:55 Comment(0)
U
0

if you are on xampp (windows) update the php.ini

php.ini path = C:\xampp\php\php.ini

;extension=intl

to

extension=intl

Uncommercial answered 6/1, 2023 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.