【问题标题】:Composer update not runComposer 更新未运行
【发布时间】:2022-01-26 11:12:20
【问题描述】:

当我在 laravel 中为任何项目运行 composer update 时遇到问题。它给了我这个错误: 无法将您的要求解析为一组可安装的软件包。

Problem 1
    - Root composer.json requires php ^7.1.3 but your php version (8.1.0) does not satisfy that requirement.
  Problem 2
    - laravel/framework[v5.7.0, ..., 5.7.x-dev] require php ^7.1.3 -> your php version (8.1.0) does not satisfy that requirement.
    - Root composer.json requires laravel/framework 5.7.* -> satisfiable by laravel/framework[v5.7.0, ..., 5.7.x-dev].

我试图从 composer.json 更改它,但仍然无法正常工作 我还尝试composer install --ignore-platform-reqs 给了我其他错误:

Generating optimized autoload files
Class Egulias\EmailValidator\Exception\ExpectedQPair located in C:/laravel/job-portal-website-in-laravel-master/vendor/egulias/email-validator/EmailValidator\Exception\ExpectingQPair.php does not comply with psr-4 autoloading standard. Skipping.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Deprecation Notice: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php:1204
Deprecation Notice: Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php:1215
Deprecation Notice: Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php:1227
Deprecation Notice: Return type of Illuminate\Container\Container::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php:1240
> @php artisan package:discover

Deprecated: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1204

Deprecated: Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1215

Deprecated: Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1227

Deprecated: Return type of Illuminate\Container\Container::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 1240

Deprecated: Method ReflectionParameter::getClass() is deprecated in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 833

Deprecated: Method ReflectionParameter::getClass() is deprecated in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 907

Deprecated: Method ReflectionParameter::getClass() is deprecated in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 833

Deprecated: Method ReflectionParameter::getClass() is deprecated in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 907

Deprecated: Return type of Illuminate\Config\Repository::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 141

Deprecated: Return type of Illuminate\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\laravel\job-portal-website-in-laravel-master\vendor\laravel\framework\src\Illuminate\Config\Repository.php on line 152

Deprecated: Return type of Illuminate\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute shou......ect.

那么您知道我应该如何处理该错误吗?有人可以帮忙吗???

【问题讨论】:

  • 看起来您已将 PHP 升级到 8.1.0,但未检查您的所有应用代码是否与它兼容。
  • 实际上我正在尝试从 git hub 下载代码。但作曲家更新不起作用

标签: php laravel azure docker laravel-5


【解决方案1】:

您的 php 版本太高 (8.1)。 Laravel 5.x 与 php 8 不兼容。
您有两种选择:

  1. Upgrade 你的 laravel 安装(按照指南至少到 8.x 版本)
  2. 降级你的php版本

【讨论】:

  • 我该怎么做?
【解决方案2】:

您已经升级了您机器中的 php 版本。因此,为了让您的 laravel 应用程序知道我已经升级到更新版本的 php,请执行以下操作,

在您的root 目录中打开composer.json 文件,在require 对象中提到了php 版本。将其更改为关注。

"php": "7.1.3|8.0",

如果这不起作用,那么只需使用您机器上安装的当前 php 版本。

"php": "8.0",

【讨论】:

    【解决方案3】:

    解决了!! 我将全局作曲家与 XAMPP 服务器一起用于 php。

    【讨论】:

      猜你喜欢
      • 2017-06-22
      • 2020-04-10
      • 2013-12-22
      • 2016-08-28
      • 2016-02-13
      • 2023-03-13
      • 2017-04-25
      • 1970-01-01
      • 2014-10-08
      相关资源
      最近更新 更多