CodeIgniter4 icon indicating copy to clipboard operation
CodeIgniter4 copied to clipboard

Bug: Missing function locale_set_default(...)

Open John-Betong opened this issue 6 years ago • 21 comments

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');

John-Betong avatar Jun 26 '20 05:06 John-Betong

Please install intl extension - this is a required component.

michalsn avatar Jun 26 '20 13:06 michalsn

Hi there, I installed intl extension but still receiving this error.

keehui avatar Sep 05 '20 03:09 keehui

intl extension required for php cli also.

cijagani avatar Sep 05 '20 07:09 cijagani

can you verify it?

cijagani avatar Sep 05 '20 07:09 cijagani

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

keehui avatar Sep 05 '20 07:09 keehui

I am using ubuntu 20.04 you shall install php7.4-intl by running the following command: sudo apt install php7.4-intl

briancalma avatar Sep 26 '20 16:09 briancalma

Please install intl extension - this is a required component.

I had this issue using XAMPP on Windows 10.

adonisnr avatar Sep 30 '20 08:09 adonisnr

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

LionsRepoVerse avatar Oct 18 '20 05:10 LionsRepoVerse

image

Above is what I now get after enabling intl in PHP.ini

DanielTheGeek avatar Nov 16 '20 07:11 DanielTheGeek

image

Above is what I now get after enabling intl in PHP.ini

Please change CI_ENVIRONMENT to development in your .env file.

paulbalandan avatar Nov 16 '20 08:11 paulbalandan

image Above is what I now get after enabling intl in PHP.ini

Please change CI_ENVIRONMENT to development in 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!

DanielTheGeek avatar Nov 16 '20 08:11 DanielTheGeek

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;

Ansulsingkang avatar Nov 27 '20 02:11 Ansulsingkang

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

shayenakhan avatar Dec 02 '20 07:12 shayenakhan

You're welcome, i'm happy hear it

Ansulsingkang avatar Dec 02 '20 08:12 Ansulsingkang

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!

ferneyvanegas avatar Dec 30 '20 19:12 ferneyvanegas

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

Imanur avatar Jun 21 '21 15:06 Imanur

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.

maslakonetop avatar Sep 09 '21 02:09 maslakonetop

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.

maslakonetop avatar Sep 09 '21 02:09 maslakonetop

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?

siilmyy avatar Aug 01 '22 06:08 siilmyy

Check phpinfo() if you have intlextension installed. If not install it. Screenshot 2022-08-01 16 57 41

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.

kenjis avatar Aug 01 '22 08:08 kenjis