为什么我使用 Composer 安装 Symfony 时出现错误

问题描述 投票:0回答:1

在composer上使用 symfony/symfony 包创建新的 symfony 项目时遇到以下错误:

No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information

In PathRepository.php line 163:
                                                                                     
  The 'url' supplied for the path (src/Symfony/Contracts) repository does not exist  
                                                                                     

我无法理解该错误消息,也无法修复它。我不知道

PathRepository.php
在哪里,并且在
Contracts
中更改
composer.json
的版本没有帮助。当这个开箱即用失败时,有什么想法吗?不建议使用不同的软件包或安装程序(如 symfony-cli)。

我跑了

composer create-project symfony.symfony starter-app-symfony
并期望:

Loading composer repositories with package information
Updating dependencies
Installing dependencies from lock file (including require-dev)
Package operations: xx installs, xx updates, xx removals
xx package suggestions were added by new dependencies, use 'composer suggest' to see details.
Generating optimized autoload files
xx packages you are using are looking for funding.
Use the 'composer fund' command to find out more!
No security vulnerability advisories found
php symfony composer-php
1个回答
0
投票

您使用的命令自 Symfony 4 起就不再起作用,它至少需要 PHP 7.4。如果您明确想要使用该版本,可以使用以下命令强制使用:

composer create-project symfony/symfony:4 project_dir

但是,由于您要开始一个新项目,强烈建议您使用最新版本的 Symfony(7)和最新版本的 PHP(8.3):

composer create-project symfony/skeleton:"7.0.*" project_dir
© www.soinside.com 2019 - 2024. All rights reserved.