Laravel Horizon, ext-pcntl and Windows

As I start using Laravel’s newest package Horizon (Introduced by Taylor Otwell on Medium or at laracon.us) to control app’s queues, I was annoyed due to a windows related problem, pcntl (PHP’s process controlling module).

After creating a new Laravel 5.5 project and adding horizon I got this error:

By lookup the error I quickly learned, pcntl doesn’t like windows at all. Therefore I needed a workaround.

Ignore all platform requirements

The simplest way to install the dependencies anyway, is to ignore all platform related requirements using the option  --ignore-platform-reqs  https://getcomposer.org/doc/03-cli.md#install

But this is a bit hard, what happen if any another package needs a PHP module that is available for windows? Not a productive-like solution I think.

Ingore just the pcntl module

Composer supports using the option  --ignore-platform-reqs and additionally specifiy which packages/modules to ignore. So you can run the following command for each install/update:

But then, everyone using your app needs to know that just to run some queue admin panel. Not really proportionate.

Configure ignorance in composer.json

I finnaly came up with ignoring just the pcntl module at all directly in the composer.json file, since it’s not critical to run my app, only to run horizon.

The version of ext-pcntl is similar to the version of php I’m using.

But notice: You are now responsible to install/enable pcntl on your prod server to be able to use it.

2 thoughts on “Laravel Horizon, ext-pcntl and Windows”

  1. typo in comand
    composer install –iNGore-platform-reqs ext-pcntl
    need to be replaced with

    composer install –ignore-platform-reqs ext-pcntl

Leave a Reply

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