When executing the command composer update –ignore-platform-reqs, an error is reported: script @php artisan package:discover –ansi handling the Post-autoload-dump event returned with error code 255

执行命令 composer update --ignore-platform-reqs 时,报错:Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255。
1. When executing the command composer update –ignore-platform-reqs, an error is reported: script @php artisan package:discover –ansi handling the Post-autoload-dump event returned with error code 255. as shown in Figure 1
执行命令 composer update --ignore-platform-reqs 时,报错:Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255。
Figure 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. Why the option –ignore-platform-reqs is added when executing the composer update command. The reason is that when executing composer update, an error is reported: it is missing from your system. install or enable phps pcntl extension.. as shown in Figure 2
为何 执行命令 composer update  时,添加了选项 --ignore-platform-reqs。原因在于 执行 composer update 时,报错:it is missing from your system. Install or enable PHP's pcntl extension.。
Figure 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. When installing Laravel/Horizon based on Composer, an error is reported: Package Laravel/Horizon at version ~5.6 has requirements incompatible with your php version, php extensions and composer version. The command was executed before: composer require “laravel/horizon:~5.6” –ignore-platform-reqs . I finally decided to uninstall Laravel/Horizon. 4. Edit composer.json, delete the line: “Laravel/Horizon”: “~5.6”, and execute the command again: composer update. Error: classHorizonnot found. as shown in Figure 3
编辑 composer.json,删除行:"laravel/horizon": "~5.6",,再次执行命令:composer update。报错:Class 'Horizon' not found。
Figure 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. Manually delete the configuration file config/horizon.php and page resource files such as css and js stored in the public/vendor/horizon folder. Delete the file app/providers/horizonserviceprovider.php. Edit the file and remove Horizon related code. 6. When the command composer update is executed again, an error is no longer reported. Learning the lesson, –ignore-platform-reqs is absolutely not usable. as shown in Figure 4
再次执行命令 composer update  时,不再报错。汲取教训,--ignore-platform-reqs 绝对不能够使用才是。
Figure 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>


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.