PHP: pthreads not loading on PHP 8.1

PHP: pthreads not loading on PHP 8.1

Problem Description:

I’m trying to add pthreads extension on PHP 8.1 TS and it doesn’t seem to work, It’s sayin that it is not installed while in fact it is.

PHP -v
PHP 8.1.10 (cli) (built: Aug 30 2022 18:05:49) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans

Here are the steps I used to install it ->

  1. Get the latest release from here ->
  2. Extract php_pthreads.dll to /php/ext
  3. Add extension=pthreads to php.ini
  4. Extract pthreadVC2 in to /php

And when I try to install Laravel Horizon this is what I get ->

Root composer.json requires PHP extension ext-pthreads * but it is missing from your system. Install or enable PHP's pthreads extension.

Solution – 1

you can use phpinfo(); method that will display all php extension you have install and make sure that you installed it in right php.ini file maybe that will fix your problem and you can also restart your localhost

Solution – 2

pthreads is not available for PHP 8.1

PHP extensions need to be compiled against the correct version of PHP, because they interact directly with code that is only guaranteed stable within one annual release (e.g. 7.0.1 and 7.0.2 are guaranteed compatible, but 7.0.0 and 7.1.0 are not). They also generally require significant source code changes between major releases, i.e. an extension written for PHP 7.0 is reasonably likely to be compilable against PHP 7.4, but not against PHP 8.0.

If you look at the downloads for an earlier version of pthreads, you’ll see that the version of PHP is included in the filename – pthreads 2.0.10 has builds available for 5.3, 5.4, 5.5, and 5.6. The last release listed, 3.1.6, only has two files available, both built for PHP 7.0.

Looking on Github, version 3.1.6 was tagged in Feb 2016, 10 months before PHP 7.1. There is a version 3.2.0 on Github, which mentions support for PHP 7.2, but this does not appear on the PECL page for the extension, which features a prominent banner:

This package is not maintained anymore and has been superseded.

Specifically, it was discontinued by the author in favour of a new extension called "parallel". Unfortunately, that extension has not yet had a release which supports PHP 8.x either.

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.