Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Missing function locale_set_default(...) #3171

Closed
John-Betong opened this issue Jun 26, 2020 · 21 comments
Closed

Bug: Missing function locale_set_default(...) #3171

John-Betong opened this issue Jun 26, 2020 · 21 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@John-Betong
Copy link

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 John-Betong added the bug Verified issues on the current code behavior or pull requests that will fix them label Jun 26, 2020
@michalsn
Copy link
Member

Please install intl extension - this is a required component.

@keehui
Copy link

keehui commented Sep 5, 2020

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

@cijagani
Copy link
Contributor

cijagani commented Sep 5, 2020

intl extension required for php cli also.

@cijagani
Copy link
Contributor

cijagani commented Sep 5, 2020

can you verify it?

@keehui
Copy link

keehui commented Sep 5, 2020

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

@briancalma
Copy link

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

@adonisnr
Copy link

Please install intl extension - this is a required component.

I had this issue using XAMPP on Windows 10.

@himanshupatel1902
Copy link

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

@DanielTheGeek
Copy link

DanielTheGeek commented Nov 16, 2020

image

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

@paulbalandan
Copy link
Member

image

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

Please change CI_ENVIRONMENT to development in your .env file.

@DanielTheGeek
Copy link

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!

@Ansulsingkang
Copy link

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;

@shayenakhan
Copy link

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

@Ansulsingkang
Copy link

You're welcome, i'm happy hear it

@ferneyvanegas
Copy link

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!

@Imanur
Copy link

Imanur commented Jun 21, 2021

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

@maslakonetop
Copy link

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
Copy link

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.

@siilmyy
Copy link

siilmyy commented Aug 1, 2022

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?

@kenjis
Copy link
Member

kenjis commented Aug 1, 2022

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.

@siilmyy
Copy link

siilmyy commented Aug 1, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests