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?
The root of the issue is that you have a missing PHP extension.
In particular:
intl
Keep in mind that this is clearly stated in the frameworks' repository README.md file.
Server Requirements
PHP version 7.4 or higher is required, with the following extensions
installed:
intl
libcurl if you plan to use the HTTP\CURLRequest library
mbstring
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.
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');
Install it via linux
sudo apt-get install php-intl
or for a PHP Version
sudo apt install php7.4-intl
if you are on xampp (windows) update the php.ini
php.ini path = C:\xampp\php\php.ini
;extension=intl
to
extension=intl
Related
Root composer.json requires PHP extension ext-gmp * but it is missing from your system. Install or enable PHP's gmp extension.
I'm getting this error, so can anyone tell me how to resolve this error?
If you are using XAMPP:
;extension=gmp
Uncomment(remove ; from ;extension=gmp) this line in your php.ini file!
I have installed php 8.0.8 on my local computer. Laravel new projects work perfect. But when I try to run Old projects it shows me error. When I try to run command
composer install
It gives me the error below:
Problem 1
- jeremy-dunn/php-fedex-api-wrapper is locked to version 5.0.1 and an update of this package was not requested.
- jeremy-dunn/php-fedex-api-wrapper 5.0.1 requires ext-soap * -> it is missing from your system. Install or enable PHP's soap extension.
To enable extensions, verify that they are enabled in your .ini files:
- C:\xampp\php\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
When I run:
composer dump-autoload
It shows this error:
Generating optimized autoload files Class App\Http\Controllers\Vendor\OrderController
located in C:/Users/Muhammad Adnan/Downloads/test-upwork-master/spree-retail/app\Http\Controllers\temp\OrderController.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Http\Resources\profile\AddressesResponse located in C:/Users/Muhammad Adnan/Downloads/test-upwork-master/spree-retail/app\Http\Resources\Profile\AddressesResponse.php does not comply with psr-4 autoloading standard. Skipping.
Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-autoload-dump script
> #php artisan package:discover --ansi
Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php:14
Stack trace:
#0 C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\artisan(20): require_once()
#1 {main}
thrown in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php on line 14
PHP Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php:14
Stack trace:
#0 C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\artisan(20): require_once()
#1 {main}
thrown in C:\Users\Muhammad Adnan\Downloads\test-upwork-master\spree-retail\bootstrap\app.php on line 14
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
Unfortunately, older versions of Laravel doesn't not support newer versions of PHP. Laravel 6 is the minimal version for PHP 8.0 support (and it is already pretty old from a web development perspective).
Of course, this is for a fresh installation, you might have code in your project that is also not PHP 8.0 compatible.
About this error:
Problem 1
- jeremy-dunn/php-fedex-api-wrapper is locked to version 5.0.1 and an update of this package was not requested.
- jeremy-dunn/php-fedex-api-wrapper 5.0.1 requires ext-soap * -> it is missing from your system. Install or enable PHP's soap extension.
The problem will be easy to fix, just install the soap extension. You seem on Windows so it should already installed but disabled.
You will have to uncomment ;extension=soap.dll in your php.ini file (or maybe in the ext directory located in your php directory, it depends).
There will probably be other extensions required but disabled, to get a full list execute composer check.
This is what is preventing composer from installing your dependencies (which lead Uncaught Error: Class "Illuminate\Foundation\Application" not found in to when you are calling composer dump-autoload).
I searched out and found a solution regarding this issue. Only single command is the solution
Note: Don't update composer.
composer install --ignore-platform-reqs
I want to test Firestore with laravel. But before i can use it, I need a couple of tools.
I'm stuck on gRPC. I installed it, it's working on my windows and I can install Firestore with Composer, but I can't get it to work with XAMPP. When I load a page I get:
Fatal error: Uncaught Google\Cloud\Core\Exception\GoogleException: The requested client requires the gRPC extension. Please see https://cloud.google.com/php/grpc for installation instructions. in /vendor/google/cloud-core/src/ClientTrait.php:75 Stack trace: #0 /vendor/google/cloud-firestore/src/FirestoreClient.php(115): Google\Cloud\Firestore\FirestoreClient->requireGrpc() #1 /app/firebase.php(18): Google\Cloud\Firestore\FirestoreClient->__construct() #2 /app/firebase.php(21): App\initialize() #3 /template.php(688): require_once('/Applications/X...') #4 /template.php(647): load_template('/Applications/X...', true) #5 /App in
/vendor/google/cloud-core/src/ClientTrait.php on line 75
It may be the case that the gRPC extention is not enabled on the php.ini file, you can enable it by:
On PHP version 7.2 and up: add extension=grpc on the php.ini file
On older PHP versions: add extension=php_grpc.dll on the php.ini file
And then restart XAMPP and the extension will be activated as showed in phpinfo() and it should work.
If this does not work, a workaround for the issue is to download the gRPC DLL and add it to your project's extentions manually. You can download the latest version on the PECL repository for gRPC (Choose a stable version), and extract the php_grpc.dll file to the extensions folder in XAMPP, which the path you can find on the php.ini.
After that, enable the extetion as described earlier and restart XAMPP again.
Let me know if this fixed your issue.
After installing laravel we get an error:
Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in C:\xampp\htdocs\laravel\public\index.php on line 50
Laravel 5.1 uses the ::class property to get string representations of a fully qualified classname. The error you're seeing is caused by this line
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
This language feature has been introduced in PHP 5.5 which is a requirement of Laravel 5.1. Your installed PHP version is probably older than 5.5. Try to update your PHP binary.
In case you are interested in why ::class is used, take a look at this answer
Same thing happened to me also. I found that web server was using my old PHP version 5. To solve it for me, I did this -
sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart
Your php version is too low.
Try version 7.0 or later php.
Your PHP version on your Xampp is lower than 5.5.9 as specified in the Laravel 5.1 doc.
Simply uninstall your current Xampp software and download a fresh copy at Apache website with this specification 5.6.12 / PHP 5.6.12 .
Do not forget to collaborate with your host provider to ensure that your hosting account runs the required PHP version (>=5.5.9) during the deployment of your Laravel 5.1 app online.
I was facing the same error but error was in app/User.php line 10.
Actually, line 10 was ok but before line 10 I was missing some php syntax.
After correct the php syntax error It was fixed. So you have to check C:\xampp\htdocs\laravel\public\index.php on line 49 carefully I am sure there is something wrong. Just try to correct. It will be fixed.
As you may have known that I switched from ubuntu to windows from my previous questions. I was working on Zend Framework on ubuntu and now working on same project in windows. Because of this switching I am facing some problems in windows which was not occurred in ubuntu.
Now I have the following error in firebug console when I go to login page:
<b>Fatal error</b>: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in <b>C:\wamp\www\vcred\library\Zend\Db\Adapter\Pdo\Mysql.php</b> on line <b>93</b><br />
Do you people know that what type of error is this and what is the solution?
I have the following configuration for database.
resources.db.adapter = "Pdo_Mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "test"
resources.db.params.charset = "utf8"
Thanks
I just had the same error with PHP 5.2.6, and all I had to do is to open php.ini (e.g. on Windows: C:\Windows\php.ini, or on Ubuntu: /etc/php5/apache2/php.ini or sg. like this) in a text editor, and remove the semicolon from the following line:
;extension=php_pdo_mysql.dll
So as a result it would look like this in php.ini:
extension=php_pdo_mysql.dll
That solved my problem.
This looks related to this bug on PHP's bugtracker : Bug #47224 MYSQL_ATTR_INIT_COMMAND is no longer available
It seems it's been fixed in SVN -- but maybe not in the version of PHP you are using ?
Quoting one of the comments :
[2009-07-02 06:43 UTC] mg at artigo
dot pl A temporary solution is to
use INT value (1002) instead of
constant.
This might be a temporary solution, until you install a new version of PHP, in which the bug is fixed ?
Looks like a Windows bug in PHP 5.3 that was fixed in SVN a while ago. You might want to try updating to the latest PHP release to see if the issue still exists.
I got the same error, on debian6, when I had not yet installed php-mysql so, I simply installed this, like this
apt-get install php5-mysql
/etc/init.d/apache2 restart
I just add it here, in case other have same problem, to save them them a few minutes of research.