Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

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

I want to create a Symfony CRUD application. These are the steps I did:

  • Downloaded and installed XAMPP from here with PHP 7.3.11 https://www.apachefriends.org/de/index.html
  • Navigated to htdocs with the CLI of Windows.
  • Created a symfony project with the command composer create-project symfony/skeleton my_project
  • Opened up my browser (Firefox 70.0.1) and navigate to the URL: localhost/my_project/public/

Here I got the error message:

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

When I check my php version in the CLI with php -v I get the result that I use PHP 7.4.0 (cli). When I check the php version by clicking the PHPInfo on the dashboard of XAMPP (localhost/dashboard/phpinfo.php), the page shows me the php version 7.3.11.

In the created symfony folder is a file called symfony.lock. There is an entry called "php": { "version": "7.4" },. Changing this entry did not solve my problem.

Any ideas how to solve this? And why I cannot install and test the newest symfony with XAMPP?

Thanks a lot guys!

Musa

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is thankfully quite easy to fix. You can tell your composer.json to install vendor libraries based on a specific version of PHP.

For instance we have a project currently in migration from PHP5 to PHP7. We cant install the PHP7 only versions of the libraries, so we add this to your composer.json:

  "config": {
    "platform": {
      "php": "5.3.29"
    }
  },

Now you should be able to install. Delete your composer.lock, then run composer install!

Here's the relevant documentation:

https://getcomposer.org/doc/06-config.md#platform


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...