0

I am trying to enable Thread with PHP script. I have followed the following steps for enabling PHP thread.

Step 1:- Download and unzip pthread lib from here

Step 2:- Copy php_pthreads.dll and paste into the php\php7.2.14\ext and php\php7.2.14\ folder.

Step 3:- and pthreadVC2.dll and paste into the apache\apache2.4.37\bin

Step 4:- Enable thread in php.ini which is located in apache\apache2.4.37\bin and after updating its look like something below.

; Whether or not to enable the dl() function.  The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
; http://php.net/enable-dl
enable_extension=On
extension=php_pthreads.dll

Step 5:- Enable thread in php.ini in which located at \php\php7.2.14

; Whether or not to enable the dl() function.  The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
; http://php.net/enable-dl
enable_dl = On
extension=php_pthreads.dll

Step 6:- I have restarted wampp server with all services.

Still, I am getting the error as

 Fatal error: Class 'Thread' not found in {PHP file with location with line number}.

Update

I have changed DLL files and restarted a server as we discussed and redirect to a new error as below.

[24-Jan-2019 10:29:20 UTC] PHP Fatal error:  The apache2handler SAPI is not supported by pthreads in Unknown on line 0
[24-Jan-2019 10:29:20 UTC] PHP Fatal error:  Unable to start pthreads module in Unknown on line 0
14
  • It seems like you're using the extension for 7.0 and not 7.2. Check this issue on their Github for a link to a version that should work for 7.2 (it's still set as version 3.1.6, but has -7.2 instead of -7.0). Commented Jan 24, 2019 at 10:13
  • @Cid i have included #!/usr/bin/php in my script. Commented Jan 24, 2019 at 10:20
  • My comment was stupid. Check @MagnusEriksson one, this will lead you to the right way Commented Jan 24, 2019 at 10:22
  • 2
    If you are using WAMPServer as you say, then #!/usr/bin/php will not be understood by Windows! Commented Jan 24, 2019 at 10:33
  • 1
    Please read the comments properly again. As stated, you were using the wrong version of the dll (and the github issue linked to a working one for PHP 7.2). Then it also states that it does not work on web servers, which includes Apache (which is a web server). So, even after upgrading the dll to the correct version, you still can't use it with Apache (or any other web server). It only works on PHP-scripts that are executed through the command line (like cmd etc). Commented Jan 24, 2019 at 10:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.