执行命令 composer update –ignore-platform-reqs 时,报错:Script @php artisan package:discover –ansi handling the post-autoload-dump event returned with error code 255

1、执行命令 composer update –ignore-platform-reqs 时,报错:Script @php artisan package:discover –ansi handling the post-autoload-dump event returned with error code 255。如图1

执行命令 composer update --ignore-platform-reqs 时,报错:Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255。

图1

PS E:/wwwroot/larabbs> composer update --ignore-platform-reqs
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate/Foundation/ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Parse error:  syntax error, unexpected '|', expecting variable (T_VARIABLE) in E:/wwwroot/larabbs/vendor/psr/log/src/LoggerInterface.php on line 30
PHP Fatal error:  Exception thrown without a stack frame in Unknown on line 0
PHP Parse error:  syntax error, unexpected '|', expecting variable (T_VARIABLE) in E:/wwwroot/larabbs/vendor/psr/log/src/LoggerInterface.php on line 30
PHP Fatal error:  Exception thrown without a stack frame in Unknown on line 0
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
PS E:/wwwroot/larabbs>

2、为何 执行命令 composer update 时,添加了选项 –ignore-platform-reqs。原因在于 执行 composer update 时,报错:it is missing from your system. Install or enable PHP’s pcntl extension.。如图2

为何 执行命令 composer update  时,添加了选项 --ignore-platform-reqs。原因在于 执行 composer update 时,报错:it is missing from your system. Install or enable PHP's pcntl extension.。

图2

PS E:/wwwroot/larabbs> composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/horizon[v5.6.0, ..., 5.x-dev] require ext-pcntl * -> it is missing from your system. Install or enable PHP's pcntl extension.
    - Root composer.json requires laravel/horizon ~5.6 -> satisfiable by laravel/horizon[v5.6.0, ..., 5.x-dev].

To enable extensions, verify that they are enabled in your .ini files:
    - C:/php-7.4.27/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
PS E:/wwwroot/larabbs>

3、基于 Composer 安装 laravel/horizon 时,报错:Package laravel/horizon at version ~5.6 has requirements incompatible with your PHP version, PHP extensions and Composer version。之前执行了命令:composer require “laravel/horizon:~5.6″ –ignore-platform-reqs 。最终决定卸载掉 laravel/horizon。

4、编辑 composer.json,删除行:”laravel/horizon”: “~5.6”,,再次执行命令:composer update。报错:Class ‘Horizon’ not found。如图3

编辑 composer.json,删除行:"laravel/horizon": "~5.6",,再次执行命令:composer update。报错:Class 'Horizon' not found。

图3

PS E:/wwwroot/larabbs> composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 9 updates, 1 removal
  - Removing laravel/horizon (v5.7.18)
  - Downgrading psr/log (2.0.0 => 1.1.4)
  - Downgrading symfony/css-selector (v6.0.2 => v5.4.2)
  - Downgrading symfony/deprecation-contracts (v3.0.0 => v2.5.0)
  - Downgrading symfony/event-dispatcher (v6.0.2 => v5.4.0)
  - Downgrading symfony/event-dispatcher-contracts (v3.0.0 => v2.5.0)
  - Upgrading symfony/service-contracts (v2.4.1 => v2.5.0)
  - Downgrading symfony/string (v6.0.2 => v5.4.2)
  - Downgrading symfony/translation (v6.0.2 => v5.4.2)
  - Downgrading symfony/translation-contracts (v3.0.0 => v2.5.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 9 updates, 1 removal
  - Removing laravel/horizon (v5.7.18)
  - Downgrading symfony/deprecation-contracts (v3.0.0 => v2.5.0): Extracting archive
  - Downgrading psr/log (2.0.0 => 1.1.4): Extracting archive
  - Downgrading symfony/css-selector (v6.0.2 => v5.4.2): Extracting archive
  - Downgrading symfony/event-dispatcher-contracts (v3.0.0 => v2.5.0): Extracting archive
  - Downgrading symfony/event-dispatcher (v6.0.2 => v5.4.0): Extracting archive
  - Downgrading symfony/string (v6.0.2 => v5.4.2): Extracting archive
  - Upgrading symfony/service-contracts (v2.4.1 => v2.5.0): Extracting archive
  - Downgrading symfony/translation-contracts (v3.0.0 => v2.5.0): Extracting archive
  - Downgrading symfony/translation (v6.0.2 => v5.4.2): Extracting archive
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate/Foundation/ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Error

  Class 'Horizon' not found

  at E:/wwwroot/larabbs/app/Providers/AuthServiceProvider.php:36
     32▕             // 动态返回模型对应的策略名称,如:// 'App/Model/User' => 'App/Policies/UserPolicy',
     33▕             return 'App/Policies//'.class_basename($modelClass).'Policy';
     34▕         });
     35▕
  ➜  36▕         /Horizon::auth(function ($request) {
     37▕             // 是否是站长
     38▕             return /Auth::user()->hasRole('Founder');
     39▕         });
     40▕     }

  1   E:/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      App/Providers/AuthServiceProvider::boot()

  2   E:/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
      Illuminate/Container/BoundMethod::Illuminate/Container/{closure}()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
PS E:/wwwroot/larabbs>

5、手动删除配置文件 config/horizon.php 和存放在 public/vendor/horizon 文件夹中的 CSS 、JS 等页面资源文件。删除文件 app/Providers/HorizonServiceProvider.php。编辑文件,删除 Horizon 相关代码。

6、再次执行命令 composer update 时,不再报错。汲取教训,–ignore-platform-reqs 绝对不能够使用才是。如图4

再次执行命令 composer update  时,不再报错。汲取教训,--ignore-platform-reqs 绝对不能够使用才是。

图4

PS E:/wwwroot/larabbs> composer update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate/Foundation/ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: intervention/image
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: mews/captcha
Discovered Package: mews/purifier
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: overtrue/laravel-lang
Discovered Package: spatie/laravel-permission
Discovered Package: summerblue/administrator
Discovered Package: summerblue/generator
Discovered Package: summerblue/laravel-active
Package manifest generated successfully.
84 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
PS E:/wwwroot/larabbs>

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250669.html

(0)
上一篇 2022年4月30日
下一篇 2022年4月30日

相关推荐

发表回复

登录后才能评论