WAMP php version is not recognized - composer error - php

I run Laravel 9 on Windows 10.
Everything worked find until installed this package:
https://spatie.be/docs/laravel-livewire-wizard/v1/introduction
and now I get this error in the browser when trying to browse my site:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.13. in C:\wamp64\www\highland9.local\vendor\composer\platform_check.php on line 24
After googling it I check all of these:
php version on Wamp shows 8.1.0
phpinfo() shows 8.1.0
localhost in the browser shows php version 8.1.0
Windows path points to: c:\wamp64\bin\php8.1.0
cmd php -v shows: 8.1.0
In my composer.json file:
it was:
"require": {
"php": "^8.0.2",
I changed it to:
"php":"^8.1.0"
and ran composer update
I tried removing the package like this:
composer remove vendor/spatie/laravel-livewire-wizard
It said there's nothing to remove.
I renamed the folder to laravel-livewire-wizardDEL
I removed the line:
"spatie/laravel-livewire-wizard": "^1.1",
from composer.json and ran composer update
Nothing helps, still get this error.
Can someone please help?

Check if you've overwritten the PHP version under the platform key in your project's local composer.json or the global ~/.composer/composer.json.
Look for the following section:
{
"platform": {
"php": "8.0.13"
}
See: Documentation - Config - platform
Use the following commands to dump the current value:
composer config platform
composer config --global platform

Related

Composer installing packages for newer version

I run app in docker on my computer and I have a problem with updating php in composer. When I change php version in require composer updates packages to version higher that I specified and get syntax error.
I am updating php from 7.4 to 8.0, the steps i made were:
I change php require to this (i have tried "^8.0.0" and "~8.0.0" too)
"require": {
"php": "8.0.*",
...
then I change Dockerfile to pull from newer image FROM php:8.0-apache (i have checked php version inside the container and it is PHP 8.0.27 (cli))
next I run docker-compose exec -T app composer update --prefer-dist --ignore-platform-reqs
then new lock file is generated and there is for example this which was installed as dependency of another package, i dont have it as my require
{
"name": "monolog/monolog",
"version": "3.2.0",
...
"require": {
"php": ">=8.1",
...
},
when i check the package which has monolog as dependency there is this "monolog/monolog": "^1.17||^2.0||^3.0", so older version was available but newer was picked and installed even when it does not meet the requirements.
Can someone help and tell me what am I doing wrong please?

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.22

Locally I have installed php 8
my composer.json looks like this
"require": {
"php": "^8.0",
I deleted the composer.lock and run composer install and I get the above error.
I tried to add
platform-check:false
delete composer.lock
run composer install
but then I get an error because I use Constructor property promotion in my codebase
So it seems that when I add platform-check:false, for some reason it runs on php < 8
P.S I didn't have that problem before, I just cloned my git repo and tried to run my app.
Your phpinfo() maybe having different version than 8.0. If so
Try
sudo apt-get install libapache2-mod-php8.0
Then restart your web server

Fatal Error: composer.lock was created for PHP version 7.4 or higher but the current PHP version is 7.1.33

At the moment, I'm facing this issue. I've tried everything: deleting composer.lock, then updating composer.json, tried to update PHP version to the highest version, still the same. When I check PHP version in CMD, it shows that my version is 7.4.10, but when I try to open "public" folder on localhost, it shows this "Fatal error: composer.lock was created for PHP version 7.4 or higher but the current PHP version is 7.1.33.".
Thanks in advance
Try to delete symfony.lock and composer.lock then deletr vendor folder and launch command composer install

Calling Composer With Specific PHP Version on Homestead

I'm using Homestead to develop a site that will be on a server with PHP 7.0. I want to use .env files, so I ran this Composer command:
composer require vlucas/phpdotenv
When I perused the file, composer.lock, I noticed that a dependency, doctrine/annotations, was requiring PHP 7.1.
I tried adding this to my composer.json file:
"config": {
"platform": {
"php": "~7.0"
}
},
When I run composer update, I get this error:
[UnexpectedValueException]
Invalid version string "~7.0"
I realize that this is because PHP 7.2 is the default version on Homestead. How do I run Composer with PHP 7.0 instead of PHP 7.2?
Executing which composer will give you this output:
/usr/local/bin/composer
The Homestead documentation discusses the multiple PHP versions supported and how to call them from the command line for Artisan. Combining that with the composer path above allows you to do this:
php7.0 /usr/local/bin/composer update
Run the command php70 and that will set PHP 7.0 to the default system version of PHP, then you can run composer normally.

Deploy PHP application with extension mongo into heroku 2015

I've just deployed php application into heroku with extension mongo db.
In previous (11/2014), it's ok.
But currently I received error messsage: The requested php extension ext-mongo * is missing from your system.
Here is the structure of project on github (using to deploy into heroku):
Root
php.ini
composer.json
composer.lock
Procfile
MySources
ext
mongo.so (this file is located inside ext folder).
php.ini:
extension_dir="/app/ext/"
extension=mongo.so
composer.json:
{
"require" : {
"silex/silex": "~1.1",
"monolog/monolog": "~1.7",
"ext-mongo": "*"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
Procfile:
web: vendor/bin/heroku-php-apache2
Any one can help me to configure or sugguest me to resolve this problem? Deploy with the lasted heroku and php 5.6.7.
You don't need the ext folder (because the extension is already available on Heroku), and you don't need the php.ini, which doesn't have any effect anyway, because you're not configuring Heroku to use it.
You need to run composer update so the ext-mongo requirement gets "frozen" to composer.lock.
If you don't have that extension installed locally on your system, then you should install it (along with a MongoDB server), because you really want to test your code locally before you blindly push it up to Heroku to see whether it works or not.
If, for any reason, you can't do that, a composer update --ignore-platform-reqs will prevent "The requested php extension ext-mongo * is missing from your system" to happen on your local machine, and generate the correct composer.lock even if the extension is missing.
This is, by the way, all clearly documented here: https://devcenter.heroku.com/articles/php-support#extensions

Categories