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->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?
CodePudding user response:
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.
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.
CodePudding user response:
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');