执行composer update之后,执行php artisan报错

1. 运行环境#

1). 当前使用的 Laravel 版本?#

2). 当前使用的 php/php-fpm 版本?#

PHP 版本:7.4.27

3). 当前系统#

CentOS 7

4). 业务环境#

本地虚拟机

5). 相关软件版本#

2. 问题描述?#

我用 Laravel 8 开发一个项目,我用 composer update 更新库的信息之后,artisan 就不能使用了。
过程如下:

1. 用 composer require kcloze/swoole-jobs 加载 kcloze/swoole-jobs 库,然后提示依赖不正确。#


[www@node1 telegram]$ composer require kcloze/swoole-jobs
Using version ^4.2 for kcloze/swoole-jobs
./composer.json has been updated
Running composer update kcloze/swoole-jobs
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 kcloze/swoole-jobs ^4.2 -> satisfiable by kcloze/swoole-jobs[v4.2.0].
    - kcloze/swoole-jobs v4.2.0 requires symfony/console ^3.4 -> found symfony/console[v3.4.0-BETA1, ..., 3.4.x-dev] but the package is fixed to v5.4.10 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require kcloze/swoole-jobs:*" to figure out if any version is installable, or "composer require kcloze/swoole-jobs:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

2. 然后我就执行了 composer update,提示如下的错误#

[www@node1 telegram]$ composer update
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 0 installs, 2 updates, 0 removals
  - Upgrading phabel-transpiler74.amphp/process (v1.1.3 => v1.1.4)
  - Upgrading psy/psysh (v0.11.6 => v0.11.7)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Downloading phabel-transpiler74.amphp/process (v1.1.4)
  - Downloading psy/psysh (v0.11.7)
  - Upgrading phabel-transpiler74.amphp/process (v1.1.3 => v1.1.4): Extracting archive
  - Upgrading psy/psysh (v0.11.6 => v0.11.7): Extracting archive
// 中间省略......

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   ErrorException

  Declaration of Illuminate\Console\Command::setHidden(bool $hidden) should be compatible with Symfony\Component\Console\Command\Command::setHidden($hidden)

  at vendor/laravel/framework/src/Illuminate/Console/Command.php:146
    142▕      * {@inheritdoc}
    143▕      *
    144▕      * @return static
    145▕      */
  ➜ 146▕     public function setHidden(bool $hidden)
    147▕     {
    148▕         parent::setHidden($this->hidden = $hidden);
    149▕         return $this;
    150▕     }

      +3 vendor frames
  4   [internal]:0
      Composer\Autoload\ClassLoader::loadClass()

  5   app/Console/Commands/PhoneOnlineSimTestCommand.php:10
      spl_autoload_call()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

3. 然后执行 php artisan,也是报了同样的错误#


百度和 Google 搜索了错误提示 “Declaration of should be compatible with”,大概是说类方法重载的问题,但是我的项目本来好好地,composer update 就出问题了。

3. 您期望得到的结果?#

希望能解决这个问题,让 artisan 运行正常(目前 web 页面还没有开发,不过 index.php 浏览器访问是正常的)。

4. 您实际得到的结果?#

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
chowjiawei
最佳答案

删除 composer.lock 和 verdoer 文件夹 执行 composer install

2年前 评论
讨论数量: 1
chowjiawei

删除 composer.lock 和 verdoer 文件夹 执行 composer install

2年前 评论