我刚刚安装了 PHP 并尝试创建一个框架项目。
我安装了 PHP 7.1,composer 并运行了命令
composer create-project symfony/website-skeleton test_symp
但它失败了,版本号不正确。
所以我认为这是旧版本,那些工具不能正确管理依赖项,所以让我们安装最新版本。
我安装了 PHP 8.1,然后重试还是失败。
这是日志:
$ composer create-project symfony/website-skeleton test_symp
Creating a "symfony/website-skeleton" project at "./test_symp"
Installing symfony/website-skeleton (v6.1.99)
- Installing symfony/website-skeleton (v6.1.99): Extracting archive
Created project in /home/simon/test_symp
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking symfony/flex (v2.2.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing symfony/flex (v2.2.5): Extracting archive
Generating optimized autoload files
1 package you are using is looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "6.1.*"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires symfony/framework-bundle 6.1.* -> satisfiable by symfony/framework-bundle[v6.1.0, ..., v6.1.11].
- symfony/framework-bundle[v6.1.0, ..., v6.1.11] require ext-xml * -> it is missing from your system. Install or enable PHP's xml extension.
Problem 2
- symfony/webapp-pack[v1.0.0, ..., v1.2.0] require symfony/security-bundle * -> satisfiable by symfony/security-bundle[v6.1.0, ..., v6.1.12].
- symfony/security-bundle[v6.1.0, ..., v6.1.12] require ext-xml * -> it is missing from your system. Install or enable PHP's xml extension.
- Root composer.json requires symfony/webapp-pack * -> satisfiable by symfony/webapp-pack[v1.0.0, ..., v1.2.0].
To enable extensions, verify that they are enabled in your .ini files:
如何获得正确的安装?
我必须安装那些:
sudo apt install php8.1-curl php8.1-xml
(在 php.ini 中添加扩展 curl 和 xml 失败,因为 curl 不是预期的(???))
之后还是报错:
$ composer require symfony/web-server-bundle --dev
./composer.json has been updated
Running composer update symfony/web-server-bundle
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires symfony/web-server-bundle 6.1.*, found symfony/web-server-bundle[v3.3.0-BETA1, ..., 3.4.x-dev, v4.0.0-BETA1, ..., 4.4.x-dev] but it does not match the constraint.