ChatGPT解决这个技术问题 Extra ChatGPT

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

When I run composer install on command promp, there exist error like this :

  Problem 1
    - Installation request for laravel/horizon v1.1.0 -> satisfiable by laravel/horizon[v1.1.0].
    - laravel/horizon v1.1.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:
    - C:\xampp-7.1\php\php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

How can I solve this error?


D
Darryl Hein

Run composer with the --ignore-platform-reqs option and specify pcntl and posix

composer install --ignore-platform-reqs

There exist error like this : Invalid argument ext-pcntl ext-posix. Use "composer require ext-pcntl ext-posix" instead to add packages to your composer.json.
Try it with only the option: composer install --ignore-platform-reqs
I just had the same issue - for some reason unknown to me, my php got unlinked (??) somehow. I found out when running php --ini to locate the loaded config that I wanted to check, and it said no config is loaded, none. At the end, all I needed was to relink PHP by brew link php71 --force and dependencies installed without a problem.
This isn't fixing the problem, it's just ignoring the error. You still need the process-control extension enabled for horizon to work as it should. You should be upgrading your php installation
I don't think this is a solution. If you supress the message, then when you get around to running horizon (which we can assume you will because its in your composer.json) then you'll get an error stating that the extension is missing.
d
dsturbid

As per the accepted answer, but you can add this to your composer.json so that you don't have to run --ignore-platform-reqs all the time

"config": {
  "platform": {
    "ext-pcntl": "8.0",
    "ext-posix": "8.0"
  }
}

I've been looking everywhere for this. Thank you!
added this but it didn't fix mine. I'm running PHP 7.3 on MAMP (on a mac)
Perfect for me, this solution worked in a window 10 PHP 7.4.15
Perfect: Worked with windows 10, PHP 8.0.3
S
Saurabh Mistry

install horizon this way :

composer require laravel/horizon --ignore-platform-reqs

then run

php artisan horizon:install

S
Sapnesh Naik

pcntl extension is not supported on Windows. (based on your XAMPP information)

Please see these github issues on laravel/horizon page #131, #78.

I suggest you use Laravel Homestead on your Windows system, It is easy to setup and will save you from many of the similar problems in future.


...and this is the better answer: how do you expect that library to work if you cannot install one of the required PHP extensions?
@NicoHaase --ignore-platform-reqs... keyword being platform. It runs on windows without those dependencies throwing a wench in the installation process. okaufmann.ch/development/laravel-horizon-ext-pcntl-and-windows
Yes, I'm aware of that. But there must be any reason that the library requires these extensions - if they are required for the library to work properly and you ignore this requirement, they won't work properly
You're missing the point, they are required on Linux, not Windows. It works fine on Windows without the those extensions.
P
Patrick.SE

If you are using docker based on a Unix image you can add it with the docker utility:

docker-php-ext-install pcntl

You can then confirm that this extension is installed and enabled inside of your container:

?> php -i | grep pcntl
/usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini,
pcntl
pcntl support => enabled

T
Trey Copeland

Just run the following:

composer install --ignore-platform-reqs

Note: pcntl is not supported on Windows


M
Md Aman Ullah

This works for me

composer require laravel/horizon --ignore-platform-reqs

Hopefully it will help.


R
Roland Allla

I have installed PHP 7.2 instead of 7.1 and everything works fine now. It appears that pcntl was not present in 7.1 but it's installed with php 7.2.


B
Beranda Kreatif

I have some problem and composer install --ignore-platform-reqs works for me

Thanks


Please don't add "thanks" as answers. They don't actually provide an answer to the question, and can be perceived as noise by its future visitors. Once you earn enough reputation, you will gain privileges to upvote answers you like. This way future visitors of the question will see a higher vote count on that answer, and the answerer will also be rewarded with reputation points. See Why is voting important.
F
FloatingKiwi

If you're running on windows 10 without homestead you can enable the linux subsystem and run horizon through that.

https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10

Then install the requirements

sudo apt install php7.2-fpm php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-cli php7.2-zip php7.2-mysql

This also can run laravel envoy too which doesn't work on windows.

It's a nice lightweight solution


D
Dharman
$composer install --ignore-platform-reqs ext-pcntl

j
jonlink

The answer to simply ignore the dependency is wrong. That isn't going to give you a working version of Horizon or whatever package you may be hoping to install. The dependencies must be installed.

Examples of how to install:

APK

sudo add php8-pcntl php8-pcntl

Yum

sudo yum install -y php-pcntl php-posix

j
javidasd

add this line

RUN docker-php-ext-install pcntl before

RUN composer install


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now