laravel5.5+ composer 安装 laravel/horizon 错误

Horizon  这个扩展只支持 redis 驱动的队列!

我在利用 composer 安装 Laravel 的队列监控 Horizon 时一直出错,错误提示如下:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for laravel/horizon ^2.0 -> satisfiable by laravel/horizon[v2.0.0].
    - laravel/horizon v2.0.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.

  To enable extensions, verify that they are enabled in your .ini files:
    - D:\wamp64\bin\php\php7.1.22\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 to its original content.

我们通过错误提示运行 php -ini 命令

https://okaufmann.ch/development/laravel-horizon-ext-pcntl-and-windows/ 这篇文章中说到 :

pcntl 的 php 扩展需要 平台的支持,对 windows 并不友好,我们可以尝试忽略在 commposer 安装时忽略平台使用的相关要求.

建议在 composer.json 文件中配置忽略配置.

 "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true,
        "platform": {
            "ext-pcntl": "7.1",
            "ext-posix": "7.1"
        }
    }

这里的版本号是要跟 php--ini 的 php 版本一直

配置完成后重新安装 : 

尽管,尽管..安装成功了..但是在 windows 下还是不能使用...!!!

在 windows 平台下安装成功后,使用会报错

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

我本地开发环境用的是 docker ,为解决这个问题,我在 docker 中安装了 pcntl 

 在 docker 容器重新 build 启动后,进入 docker 容器中运行 php artisan horizon 命令成功了!也正常可以执行.

 

总结起来就是, windows 平台不能实现 horizon 这个功能

 

参考

https://okaufmann.ch/development/laravel-horizon-ext-pcntl-and-windows/

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值