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?

Pol
  • 454
  • 2
  • 4
  • 12
  • Please follow this solution here. I answer this question [enter link description here](https://stackoverflow.com/a/58409729/11716584) – Chibueze Agwu Mar 13 '22 at 08:26

4 Answers4

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.

steven7mwesigwa
  • 5,701
  • 3
  • 20
  • 34
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');
Pol
  • 454
  • 2
  • 4
  • 12
  • Disabling the use of one function in the framework doesn't solve the fundamental issue. – steven7mwesigwa Mar 11 '22 at 08:08
  • 1
    You are right [Steven](https://stackoverflow.com/users/7376590/steven7mwesigwa). 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! – Pol Mar 11 '22 at 11:36
0

Install it via linux

sudo apt-get install php-intl

or for a PHP Version

sudo apt install php7.4-intl 
dazzafact
  • 2,570
  • 3
  • 30
  • 49
0

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

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

;extension=intl

to

extension=intl

chaky
  • 117
  • 2
  • 13