致命错误:composer.lock 是为 PHP 7.4 或更高版本创建的,但当前的 PHP 版本是 7.3.11 [英] Fatal Error: composer.lock was created for PHP version 7.4 or higher but the current PHP version is 7.3.11

查看:39
本文介绍了致命错误:composer.lock 是为 PHP 7.4 或更高版本创建的,但当前的 PHP 版本是 7.3.11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个 Symfony CRUD 应用程序.这些是我做的步骤:

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

  • 使用 PHP 7.3.11 从这里下载并安装 XAMPP https://www.apachefriends.org/de/index.html
  • 使用 Windows 的 CLI 导航到 htdocs.
  • 使用命令composer create-project symfony/skeleton my_project
  • 创建了一个symfony项目
  • 打开我的浏览器 (Firefox 70.0.1) 并导航到 URL:localhost/my_project/public/

这里我收到了错误消息:

Here I got the error message:

致命错误:composer.lock 是为 PHP 7.4 或更高版本创建的,但当前的 PHP 版本是 7.3.11.

当我在 CLI 中使用 php -v 检查我的 php 版本时,我得到的结果是我使用的是 PHP 7.4.0 (cli).当我通过单击 XAMPP 仪表板上的 PHPInfo(localhost/dashboard/phpinfo.php)检查 php 版本时,页面显示 php 版本 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.

在创建的 symfony 文件夹中有一个名为 symfony.lock 的文件.有一个条目叫"php": { "version": "7.4" },.更改此条目并没有解决我的问题.

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.

任何想法如何解决这个问题?为什么我不能用 XAMPP 安装和测试最新的 symfony?

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

非常感谢大家!

穆萨

推荐答案

幸运的是,这很容易解决.您可以告诉 composer.json 安装基于特定 PHP 版本的供应商库.

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

例如,我们有一个项目目前正在从 PHP5 迁移到 PHP7.我们无法安装仅 PHP7 版本的库,因此我们将其添加到您的 composer.json 中:

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"
    }
  },

现在您应该可以安装了.删除你的composer.lock,然后运行composer install

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

以下是相关文档:

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

这篇关于致命错误:composer.lock 是为 PHP 7.4 或更高版本创建的,但当前的 PHP 版本是 7.3.11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆