【问题标题】:PHP Laravel error - Your requirements could not be resolved to an installable set of packagesPHP Laravel 错误 - 您的要求无法解析为一组可安装的软件包
【发布时间】:2022-11-13 19:31:42
【问题描述】:

我正在尝试在 WSL2 ubuntu 中创建 laravel 项目。我在 WSL 根目录中有项目文件夹 (www),在该文件夹中我有 laravel_test 子文件夹。当我跑步时

composer create-project laravel/laravel example-app

但我遇到了一个错误您的要求无法解决为一组可安装的软件包。我该如何解决这个问题?

root@LAPTOP-R27NIA9B:~/www/laravel_test# composer create-project laravel/laravel example-app
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? Y
Creating a "laravel/laravel" project at "./example-app"
Installing laravel/laravel (v9.3.5)
  - Installing laravel/laravel (v9.3.5): Extracting archive
Created project in /root/www/laravel_test/example-app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
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 laravel/pint ^1.0 -> satisfiable by laravel/pint[v1.0.0, v1.1.0, v1.1.1].
    - laravel/pint[v1.0.0, ..., v1.1.1] require ext-xml * -> it is missing from your system. Install or enable PHP's xml extension.
  Problem 2
    - phpunit/phpunit[9.5.10, ..., 9.5.x-dev] require ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
    - Root composer.json requires phpunit/phpunit ^9.5.10 -> satisfiable by phpunit/phpunit[9.5.10, ..., 9.5.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/8.1/cli/php.ini
    - /etc/php/8.1/cli/conf.d/10-opcache.ini
    - /etc/php/8.1/cli/conf.d/10-pdo.ini
    - /etc/php/8.1/cli/conf.d/20-calendar.ini
    - /etc/php/8.1/cli/conf.d/20-ctype.ini
    - /etc/php/8.1/cli/conf.d/20-exif.ini
    - /etc/php/8.1/cli/conf.d/20-ffi.ini
    - /etc/php/8.1/cli/conf.d/20-fileinfo.ini
    - /etc/php/8.1/cli/conf.d/20-ftp.ini
    - /etc/php/8.1/cli/conf.d/20-gettext.ini
    - /etc/php/8.1/cli/conf.d/20-iconv.ini
    - /etc/php/8.1/cli/conf.d/20-phar.ini
    - /etc/php/8.1/cli/conf.d/20-posix.ini
    - /etc/php/8.1/cli/conf.d/20-readline.ini
    - /etc/php/8.1/cli/conf.d/20-shmop.ini
    - /etc/php/8.1/cli/conf.d/20-sockets.ini
    - /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
    - /etc/php/8.1/cli/conf.d/20-sysvsem.ini
    - /etc/php/8.1/cli/conf.d/20-sysvshm.ini
    - /etc/php/8.1/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-xml --ignore-platform-req=ext-dom` to temporarily ignore these required extensions.

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    你应该只安装 ext-xml

    sudo apt-get install php-xml
    

    laravel/pint 需要这个包才能正确运行

    【讨论】:

    • 我看到了两个问题,而你只解决了一个问题。
    • 以前的问题都没有了。现在它说: 1 问题 - spatie/laravel-ignition[1.0.0, ..., 1.3.1] 需要 ext-curl * -> 你的系统中缺少它。安装或启用 PHP 的 curl ext,但 curl 扩展已经安装。我想我必须以某种方式启用 curl,请问您知道该怎么做吗?
    • 安装它: sudo apt-get install php-curl
    • 谢谢楼主,解决了我的问题。我输入 curl 而不是 php-curl
    【解决方案2】:

    我的答案与 Farid Saravi 的答案没有什么不同,它也解决了我的问题 只想为我出现的第二个问题添加答案

    提到我正在使用 linux ubuntu 22.04

    问题 1

    • 根 composer.json 需要 laravel/pint ^1.0 -> 可由 laravel/pint[v1.0.0, ..., v1.2.0] 满足。 - laravel/pint[v1.0.0, ..., v1.2.0] 需要 ext-xml * -> 你的系统中缺少它。安装或启用 PHP 的 xml 扩展。

    及其答案

    sudo apt-get install php-xml
    

    问题 2

    spatie/laravel-ignition[1.0.0, ..., 1.6.1] 需要 ext-curl * -> 您的系统中缺少它。安装或启用 PHP 的 curl 扩展。 - 根 composer.json 需要 spatie/laravel-ignition ^1.0 -> 可由 spatie/laravel-ignition[1.0.0, ..., 1.6.1] 满足。

    及其答案

    sudo apt-get install php-curl
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-20
      • 2019-08-22
      • 2015-06-20
      • 2017-07-25
      • 1970-01-01
      • 2015-06-01
      • 2018-04-18
      相关资源
      最近更新 更多