Closed rogerdawkins closed 2 years ago
That error means that there are dependencies in your composer.json file that require PHP 8.0, but the site you created in Nitro is using PHP 7.4.
If your run nitro edit
, then change the site you added to use PHP 8.0, instead of 7.4, save the file, then run nitro apply
, that'll solve it for you.
Thanks Brad, I can understand the error message, but all I've done is run nitro create <project-name>
to create a new project. I answered the questions and selected PHP 7.4 as that is what I need to use in this case and I get the error. Is it not possible to use nitro create
to start a project that uses PHP 7.4?
Is it not possible to use nitro create to start a project that uses PHP 7.4?
You can, but presumably, you ran nitro create on a folder that had an existing composer.json file in it, no? If that's the case, that composer.json file has dependencies that require PHP 8.
I was just trying to test out Docker and Nitro. They were all fresh installs and the folder for the project did NOT exist.
@rogerdawkins got it... in this case, when you run nitro create <project-name>
, behind the scenes, it's passing --ignore-platform-reqs
in behind the scenes (https://getcomposer.org/doc/03-cli.md), which is causing the PHP version mismatch for the dependency.
A workaround would be to change the site to use PHP (in step 6 of your original post). Alternatively, if you want to use PHP 7.4, then you can nitro add
to create a site, nitro ssh
into the container, then composer create-project
and it should pull in the correct dependencies.
I can give you some more detailed steps if you want to go down that latter route.
I tried the second option. I was able to nitro add
and nitro ssh
and then run the composer create-project
but not sure what I need to enter for the IP and database credentials.
@rogerdawkins database creds are user: nitro
pass: nitro
. You can get the hostname to use to connect to the database via these instructions: https://craftcms.com/docs/nitro/2.x/usage.html#connecting-to-the-database
Thanks @angrybrad. Sorry, I should have thought of trying context
. All working now.
I know this is closed but is there a better workaround to getting this resolved. I am experiencing the same bug and while the process @angrybrad described worked, it was certainly not ideal.
@richard-ell this is resolved in the upcoming Nitro 3, but it took some architectural changes that are impractical to backport, ufortunately.
Would an another alternative be to manually download and extract Craft then run nitro add .
?
Just got the same error creating a site. The host the site will end up on is running 7.4 so we need to build the site on 7.4 from the start
I went through the steps the same as OP. Ran nitro create site-name
, set the hostname, set the web root, selected PHP 7.4, added a db, then updated the .env file.
I then noticed the following before the hosts were updated:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.24. in /app/vendor/composer/platform_check.php on line 24
Call Stack:
0.0001 399048 1. {main}() /app/craft:0
0.0001 401816 2. require('/app/bootstrap.php') /app/craft:8
0.0002 402896 3. require_once('/app/vendor/autoload.php') /app/bootstrap.php:11
0.0003 416960 4. ComposerAutoloaderInit8b38923fcbc98f32318e686c2016e522::getLoader() /app/vendor/autoload.php:7
0.0003 421576 5. require('/app/vendor/composer/platform_check.php') /app/vendor/composer/autoload_real.php:25
0.0003 422152 6. trigger_error($message = 'Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.24.', $error_type = 256) /app/vendor/composer/platform_check.php:24
Script @php craft setup/welcome handling the post-create-project-cmd event returned with error code 255
composer create-project completed 🤘
Same issue here. Does this mean we have to wait for nitro 3 to create new craft projects with nitro?
@jamiematrix @jskrivanek this error is specific to nitro create, but all the files are downloaded when the error happens, so another workaround would be to:
nitro create mysite
cd mysite
composer config platform-check false
composer update --ignore-platform-reqs
craft setup/welcome
@angrybrad I'm getting this error installing a fresh site with PHP 7.4 or PHP 8.0. Nitro creates the same composer.json file for both sites with the same platform requirements.
...
"platform": {
"php": "7.2.5"
}
It seem like I can resolve this without using platform-check false
or --ignore-platform-reqs
. The composer.lock file is just out of sync with the composer.json that's created.
These steps work for me:
nitro create mysite
cd mysite
composer update
or nitro composer update
(same result)craft setup/welcome
Hi @angrybrad this is still an issue, basically creating new project and selecting php version doesn't make sense at the moment. The above "workaround" does help indeed with getting Craft to work with php 7.4 as selected. But then again trying to install commerce new error comes up.
Problem 1
- symfony/deprecation-contracts v3.0.0 requires php >=8.0.2 -> your php version (7.4;
Edit: fixed commerce install with --ignore-platform-reqs
flag
Basically selecting php8 I guess is a way to go?
dp
@davorpeic @angrybrad I recently created a new site via Nitro (to play with Craft 4) and even selecting PHP8 from the start created a composer.json file with PHP set to 7.4
If you're having this issue after using Nitro Create
, just delete the vendor folder and the composer.lock file and then run nitro composer install
and you're all set.
Description
After a fresh install of Docker and nitro, when I run
nitro create
I get a Fatal error due to composer dependencies issue. I suspect it is because during the install I selected PHP 7.4. This installation is on a Mac and installed using thebash <(curl -sLS http://installer.getnitro.sh)
option.Steps to reproduce
nitro create nitro-test
@php craft setup/welcome
at which point I getFatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.4.24. in /app/vendor/composer/platform_check.php on line 24
I did a search for 8.0.2 in the generated files and there are several that include require php >=8.0.2. The composer.lock file has a require of >=8.0.2 in the symfony/filesystem, symfony/finder, symfony/service-contracts and symfony/string sections.
Additional info