作曲家更新未 运行

Composer update not run

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

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)。 Laravel 5.x 不兼容 php 8.
您在这里有两个选择:

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

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

在您的 root 目录中打开 composer.json 文件,在 require 对象中提到了 php 版本。改成如下。

"php": "7.1.3|8.0",

如果这不起作用,则仅使用您计算机上安装的当前 php 版本。

"php": "8.0",

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