Bug: Missing function locale_set_default(...)
Download: git clone https://github.com/codeigniter4/CodeIgniter4.git
File: ./system/CodeIgniter/CodeIgniter.php
Output:
Fatal error: Uncaught Error: Call to undefined function CodeIgniter\locale_set_default() in /var/www/CodeIgniter4/system/CodeIgniter.php:184 Stack trace: #0 /var/www/CodeIgniter4/system/bootstrap.php(181): CodeIgniter\CodeIgniter->initialize() #1 /var/www/CodeIgniter4/public/index.php(36): require('/var/www/CodeIg...') #2 {main} thrown in /var/www/CodeIgniter4/system/CodeIgniter.php on line 184
Fix:
/**
* Handles some basic app and environment setup.
*/
public function initialize()
{
// Set default locale on the server
// John REMOVED MISSING FUNCTION locale_set_default
// locale_set_default($this->config->defaultLocale ?? 'en');
Please install intl extension - this is a required component.
Hi there, I installed intl extension but still receiving this error.
intl extension required for php cli also.
can you verify it?
php --info | grep intl
Configure Command => './configure' '--prefix=/usr/local/Cellar/[email protected]/7.3.22' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/7.3' '--with-config-file-path=/usr/local/etc/php/7.3' '--with-config-file-scan-dir=/usr/local/etc/php/7.3/conf.d' '--with-pear=/usr/local/Cellar/[email protected]/7.3.22/share/[email protected]/pear' '--enable-bcmath' '--enable-calendar' '--enable-dba' '--enable-dtrace' '--enable-exif' '--enable-ftp' '--enable-fpm' '--enable-intl' '--enable-mbregex' '--enable-mbstring' '--enable-mysqlnd' '--enable-opcache-file' '--enable-pcntl' '--enable-phpdbg' '--enable-phpdbg-readline' '--enable-phpdbg-webhelper' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--enable-zip' '--with-apxs2=/usr/local/opt/httpd/bin/apxs' '--with-bz2=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-curl=/usr/local/opt/curl-openssl' '--with-fpm-user=_www' '--with-fpm-group=_www' '--with-freetype-dir=/usr/local/opt/freetype' '--with-gd' '--with-gettext=/usr/local/opt/gettext' '--with-gmp=/usr/local/opt/gmp' '--with-iconv=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-icu-dir=/usr/local/opt/icu4c' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-kerberos=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-layout=GNU' '--with-ldap=/usr/local/opt/openldap' '--with-ldap-sasl=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-libxml-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-libedit=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-libzip' '--with-mhash=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-ndbm=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-openssl=/usr/local/opt/[email protected]' '--with-password-argon2=/usr/local/opt/argon2' '--with-pdo-dblib=/usr/local/opt/freetds' '--with-pdo-mysql=mysqlnd' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--with-pdo-pgsql=/usr/local/opt/libpq' '--with-pdo-sqlite=/usr/local/opt/sqlite' '--with-pgsql=/usr/local/opt/libpq' '--with-pic' '--with-png-dir=/usr/local/opt/libpng' '--with-pspell=/usr/local/opt/aspell' '--with-sodium=/usr/local/opt/libsodium' '--with-sqlite3=/usr/local/opt/sqlite' '--with-tidy=/usr/local/opt/tidy-html5' '--with-unixODBC=/usr/local/opt/unixodbc' '--with-webp-dir=/usr/local/opt/webp' '--with-xmlrpc' '--with-xsl=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr' '--with-zlib=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr'
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0
It show this when i check intl extension
I am using ubuntu 20.04 you shall install php7.4-intl by running the following command:
sudo apt install php7.4-intl
Please install
intlextension - this is a required component.
I had this issue using XAMPP on Windows 10.
Issue resolved in Ubuntu
edit php.ini file located at /etc/php/7.4/apache2/php.ini
remove ; before "extension=intl"
means ;extension=intl
should become
extension=intl

Above is what I now get after enabling intl in PHP.ini
Above is what I now get after enabling
intlinPHP.ini
Please change CI_ENVIRONMENT to development in your .env file.
Above is what I now get after enabling
intlinPHP.iniPlease change
CI_ENVIRONMENTtodevelopmentin your .env file.
That worked fine but another thing that worked too was setting up a virtual host configuration for my local domain and adding it into the hosts file. Now everything works fine at mydomain.local. Thank you very much!
try to change in /system/Codeignater.php line 184 locale_set_default($this->config->defaultLocale ?? 'en');
become:
if( function_exists('locale_set_default' ) ) :
locale_set_default($this->config->defaultLocale ?? 'en');
endif;
try to change in /system/Codeignater.php line 184 locale_set_default($this->config->defaultLocale ?? 'en');
become:
if( function_exists('locale_set_default' ) ) : locale_set_default($this->config->defaultLocale ?? 'en'); endif;
thanks... solved my issue
You're welcome, i'm happy hear it
try to change in /system/Codeignater.php line 184 locale_set_default($this->config->defaultLocale ?? 'en');
become:
if( function_exists('locale_set_default' ) ) : locale_set_default($this->config->defaultLocale ?? 'en'); endif;
Funcionó! Thanx man!
Permisi mau tanya dong, kalau mengalami eror seperti ini bagaimana solusinya ya?
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\ci4\vendor\codeigniter4\framework\system\Commands\Server/rewrite.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0
Mohon bantuanya semua, terima kasih
try to change in /system/Codeignater.php line 184 locale_set_default($this->config->defaultLocale ?? 'en');
become:
if( function_exists('locale_set_default' ) ) : locale_set_default($this->config->defaultLocale ?? 'en'); endif;
Hi Thanks alot. It solved my issued, when I deploy on my hosting.
Permisi mau tanya dong, kalau mengalami eror seperti ini bagaimana solusinya ya?
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\ci4\vendor\codeigniter4\framework\system\Commands\Server/rewrite.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0
Mohon bantuanya semua, terima kasih
Lihat deh jawaban https://github.com/codeigniter4/CodeIgniter4/issues/3171#issuecomment-737053932 Aku berhasil solved pake itu.
Permisi mau tanya dong, kalau mengalami eror seperti ini bagaimana solusinya ya? Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\ci4\vendor\codeigniter4\framework\system\Commands\Server/rewrite.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0 Mohon bantuanya semua, terima kasih
Lihat deh jawaban #3171 (comment) Aku berhasil solved pake itu.
tapi di aku kok ga ada folder system? dimana ya itu file codeiniter 4?
Check phpinfo() if you have intlextension installed. If not install it.

On CLI you can check with php -m:
$ php -m | grep intl
intl
All you need to do is to install intlextension. Because it is a necessary extension.
To skip locale_set_default() code create another problem.