在运行 composer install时
报相关扩展的错误,错误如下:
Problem 1 - laravel/horizon[v4.3.0, ..., 4.x-dev] require ext-pcntl * -> it is missing from your system. Install or enable PHP's pcntl extension. - Root composer.json requires laravel/horizon ^4.3 -> satisfiable by laravel/horizon[v4.3.0, ..., 4.x-dev].To enable extensions, verify that they are enabled in your .ini files: - D:\phpstudy\phpstudy_pro\Extensions\php\php7.3.4nts\php.iniYou can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
由于 Horizon 需要 php 的 pcntl 扩展,而 win 环境无法安装该扩展,导致无法成功安装 Horizon,进而导致本地环境无法使用,artisan 命令无法使用。
解决办法:
Windows 环境安装 Horizon 报错解决:
composer install/update --ignore-platform-reqs
composer install –ignore-platform-reqs 就相当于设置了忽略版本匹配。如果方法1不行可以使用方法2
打开composer.json
文件,添加如下配置
"config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true, "platform": { "ext-pcntl": "7.2", "ext-posix": "7.2" }},
重新运行
composer install
我使用方法2 成功 解决错误,方法1没有使用过。用过的可以反馈
参考:https://www.ziruchu.com/art/349 https://learnku.com/articles/29150