基于 Composer 安装 laravel/horizon 时,报错:Package laravel/horizon at version ~5.6 has requirements incompatible with your PHP version, PHP extensions and Composer version

1、基于 Composer 安装 laravel/horizon 时,报错:Package laravel/horizon at version ~5.6 has requirements incompatible with your PHP version, PHP extensions and Composer version。如图1

基于 Composer 安装 laravel/horizon 时,报错:Package laravel/horizon at version ~5.6 has requirements incompatible with your PHP version, PHP extensions and Composer version。

图1

PS E:/wwwroot/larabbs> composer require "laravel/horizon:~5.6"


  [InvalidArgumentException]
  Package laravel/horizon at version ~5.6 has requirements incompatible with your PHP version, PHP extensions and Com
  poser version:
    - laravel/horizon v5.7.17 requires ext-pcntl * but it is not present.
    - laravel/horizon v5.7.17 requires ext-posix * but it is not present.


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-scripts] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>]...

PS E:/wwwroot/larabbs>

2、基于提示信息,安装 PHP 扩展:pcntl、posix,但是 pcntl 在 Windows 下不可用。如图2

基于提示信息,安装 PHP 扩展:pcntl、posix,但是 pcntl 在 Windows 下不可用。

图2

3、最终决定,先在本地 Windows 中安装起来,后续在 Linux 中运行就是。启用选项:–ignore-platform-reqs ,忽略所有平台要求(php、hhvm、lib-* 和 ext-*)并强制安装,即使本地机器不满足这些要求。安装成功。如图3

最终决定,先在本地 Windows 中安装起来,后续在 Linux 中运行就是。启用选项:--ignore-platform-reqs ,忽略所有平台要求(php、hhvm、lib-* 和 ext-*)并强制安装,即使本地机器不满足这些要求。安装成功。

图3

PS E:/wwwroot/larabbs> composer require "laravel/horizon:~5.6" --ignore-platform-reqs
./composer.json has been updated
Running composer update laravel/horizon
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking laravel/horizon (v5.7.17)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Downloading laravel/horizon (v5.7.17)
  - Installing laravel/horizon (v5.7.17): Extracting archive
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
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/horizon
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: summerblue/generator
Discovered Package: summerblue/laravel-active
Package manifest generated successfully.
83 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
Copied Directory [/vendor/laravel/horizon/public] To [/public/vendor/horizon]
Publishing complete.
PS E:/wwwroot/larabbs>

4、安装完毕,浏览器打开 larabbs.local/horizon 访问控制台。符合预期。如图4

安装完毕,浏览器打开 larabbs.local/horizon 访问控制台。符合预期。

图4

5、只不过不能够使用 horizon 命令来启动队列系统和任务监控。报错:Call to undefined function Laravel/Horizon/Console/pcntl_async_signals() 。如图5

只不过不能够使用 horizon 命令来启动队列系统和任务监控。报错:Call to undefined function Laravel/Horizon/Console/pcntl_async_signals()

图5

PS E:/wwwroot/larabbs> php artisan horizon
Horizon started successfully.

   Error

  Call to undefined function Laravel/Horizon/Console/pcntl_async_signals()

  at E:/wwwroot/larabbs/vendor/laravel/horizon/src/Console/HorizonCommand.php:48
     44▕         );
     45▕
     46▕         $this->info('Horizon started successfully.');
     47▕
  ➜  48▕         pcntl_async_signals(true);
     49▕
     50▕         pcntl_signal(SIGINT, function () use ($master) {
     51▕             $this->line('Shutting down...');
     52▕

  1   E:/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      Laravel/Horizon/Console/HorizonCommand::handle(Object(Laravel/Horizon/Repositories/RedisMasterSupervisorRepository))

  2   E:/wwwroot/larabbs/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
      Illuminate/Container/BoundMethod::Illuminate/Container/{closure}()
PS E:/wwwroot/larabbs>

6、后续在安装其他扩展时,也需要添加参数: –ignore-platform-reqs,否则会报错。不过,强烈建议不要使用此参数,后续会出现不可预计的问题。如图6

后续在安装其他扩展时,也需要添加参数: --ignore-platform-reqs,否则会报错。不过,强烈建议不要使用此参数,后续会出现不可预计的问题。

图6

PS E:/wwwroot/larabbs> composer require "spatie/laravel-permission:~3.0"
./composer.json has been updated
Running composer update spatie/laravel-permission
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/horizon is locked to version v5.7.17 and an update of this package was not requested.
    - laravel/horizon v5.7.17 requires ext-pcntl * -> it is missing from your system. Install or enable PHP's pcntl extension.

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.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
PS E:/wwwroot/larabbs> git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
PS E:/wwwroot/larabbs> composer require "spatie/laravel-permission:~3.0"  --ignore-platform-reqs
./composer.json has been updated
Running composer update spatie/laravel-permission
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking spatie/laravel-permission (3.18.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Downloading spatie/laravel-permission (3.18.0)
  - Installing spatie/laravel-permission (3.18.0): 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
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: intervention/image
Discovered Package: laravel/horizon
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/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
Copied Directory [/vendor/laravel/horizon/public] To [/public/vendor/horizon]
Publishing complete.
PS E:/wwwroot/larabbs>

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

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

相关推荐

发表回复

登录后才能评论