'codeigniter 4 running error first time with xampp

Uncaught Error: Call to undefined function CodeIgniter\locale_set_default() 
in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184 
Stack trace: 
#0 C:\xampp\htdocs\sunpay-ci4\system\bootstrap.php(181): CodeIgniter\CodeIgniter->initialize() 
#1 C:\xampp\htdocs\sunpay-ci4\public\index.php(36): require('C:\\xampp\\htdocs...') 
#2 {main} thrown in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php on line 184

I don't understand this error, the first page works if I drop this package.

php


Solution 1:[1]

Try opening php.ini from the control panel: Apache row -> Config -> php.ini

Then enable intl extension by removing ; in front of extension=intl

Edit: the reason it fails is because the intl extension is disabled by default in xampp

Solution 2:[2]

Recently I stuck on the same problem on CI version 4.0.4.

Follow the steps to fix it.

  1. Click on "config" from the xampp control panel.

enter image description here

  1. Then click on php.ini option.

enter image description here

  1. Then it will open on your default text editor application (for me it is Notepad). then click on find option.

enter image description here

  1. Then search for ";extension=intl".

enter image description here

  1. replace ";extension=intl" with "extension=intl".

That's all. Thanks.

Solution 3:[3]

  1. get your php version by put this code : phpinfo();die(); in your index.php after <?php so it looks like like <?php phpinfo();die();

PHP Version 7.2.24-0ubuntu0.18.04.7

  1. jump to /etc/php/{your php version}/apache2 folder; example : /etc/php/7.2/apache2 and open php.ini then find ;extension=intl and remove the semicolon ;

  2. open your terminal then write or copy paste this command sudo systemctl restart apache2 and press ENTER

  3. open your CI 4 again in your browser.

Welcome to CodeIgniter 4.0.4 The small framework with powerful features

============================================================================== if you still get the same error please try to install intl extension using this command in your terminal:

sudo apt install php{your php version}-intl
sudo systemctl restart apache2`

example :

sudo apt install php7.2-intl
sudo systemctl restart apache2

open your CI 4 again in your browser.

Welcome to CodeIgniter 4.0.4 The small framework with powerful features

=============================================================================

#NB : dont forget to remove phpinfo();die(); in the first step sorry for my bad english

Solution 4:[4]

Just go to the mentioned line in display in error. C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184

You can find it here: root folder/system/CodeIgniter.php

on line no 184 you will find the below code.

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

just comment it like this.

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

Now, the code is working.

Solution 5:[5]

if your have installed Apache, PHP, MYSQL manually, then set locale to app in .env file:

app.locale = "en"

save and restart apache service

Solution 6:[6]

When i started a new project i got this error on welcome screen. Fatal error: Uncaught Error: //pp\Views\welcome_message.php:222 Stack trace: #0 {main} thrown in. It appears like there is a problem with the installation of codeigniter but in fact it is an echo error in line 222 of the welcom_message.php page go there an remove the <?= CodeIgniter\CodeIgniter::CI_VERSION ?> from line 222 it should look like this

 <div class="heroe">

        <h1>Welcome to CodeIgniter </h1>

        <h2>The small framework with powerful features</h2>

    </div>

Then it will echo hello screen correctly

Solution 7:[7]

1.search for intl and uncomment this extension in php.ini file by removing ; from begin of line extension=intl
2. restart Apache service by stop and starting it again from xampp control panel

Solution 8:[8]

Usually to get round this try these three points:

  1. Ensure .writable folder is writable with file permissions 0777 (must have leading zero)

  2. Try setting the following in index.php -> $_SERVER['CI_ENVIRONMENT'] = 'development'; and toggle with $_SERVER['CI_ENVIRONMENT'] = 'production' in .env file;

  3. Access this file(CodeIgniter.php) in the following directory: project_folder/vendor/codeigniter4/framework/system/CodeIgniter.php

    public function initialize() { if( function_exists('locale_set_default' )): locale_set_default($this->config->defaultLocale ?? 'en'); endif;}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman
Solution 2 Sushil
Solution 3
Solution 4 theWellHopeErr
Solution 5 sunil
Solution 6 Weyers de Lange
Solution 7 Andrew
Solution 8 Isaac Quarshie