Fatal Error: Class 'Thread not found in
Im getting this title as an error.
my php version is 5.5.9 - php-5.5.9-Win32-VC11-x86 thread sage php_pthreads-0.1.0-5.5-ts-vc11-x64
I did corectly copy pThreadsVC2.dll in the same folder as php.exe,php-cgi.exe. I also did put the file php_pthreads.dll in the ext directory
In my php.ini the extension_dir is corectly set to the ext folder that has the php_pthreads.dll.
I also saw on internet that some poeple say to put this following line extension=php_pthreads.dll In php.ini
After all that I still can't use pthreads. If Someone has an idea, What should I do
Thanks for any help
@nic335 sorry for big delays. do you use thread safe version of PHP? Create a PHP file called 'test.php' and put the following code and run it.
<?php
phpinfo();
?>
Check if "Thread Safety" is enabled or not. You need it enabled. Otherwise get a thread-safe PHP version.
You will also include this
extension=php_pthreads.dll
in php.ini. It seems your configuration is correct. Anyway please go through this requirements/installation steps again. Kindly cross-check your installation.
Create a file with sample code given in above link to check if your installation is correct. If you run into problems, post it here.
Thank you for your help.
Unfortunately I still did not got able to make it work.
Just to be sure I was doing it correctly i did re-downloaded php 5.5 "php-5.5.9-Win32-VC11-x86.zip" Witch is a thread safe version.
Followed the instruction to install, Putted the two files at the right place. Then Added the line in php.ini "extension=php_pthreads.dll"
Did run a litle test script and still I get the same error that the pThreads class don't exist.
This is the exsact code that im trying to run for test purposes.
<?php
class AsyncOperation extends Thread {
public function __construct($arg) {
$this->arg = $arg;
}
public function run() {
if ($this->arg) {
$sleep = mt_rand(1, 10);
printf('%s: %s -start -sleeps %d' . "\n", date("g:i:sa"), $this->arg, $sleep);
sleep($sleep);
printf('%s: %s -finish' . "\n", date("g:i:sa"), $this->arg);
}
}
}
// Create a array
$stack = array();
//Iniciate Miltiple Thread
foreach ( range("A", "D") as $i ) {
$stack[] = new AsyncOperation($i);
}
// Start The Threads
foreach ( $stack as $t ) {
$t->start();
}
?>
in the folowing link I have put the reponce of phpinfo() and my php.ini file ( in case It can help ) https://gist.github.com/nic335/9355842
PHP extension build MISMATCH, a reason for incorrect pthreads PHP installation.
This is a common issue that you may have PHP extension build VC11 installed in your system but you downloaded VC9 or incompatible one. Check windows binaries download page to get pthreads release of VC that matches with your PHP extension build. This needs to be matched. Also check if you install the extension for 32-bit OS (x86) or 64-bit OS (x64). After verifying, download the right one that fits your installation. You may find the compatible and latest pthread release here You can check it just by executing this,
<?php
phpinfo();
?>
After installing correctly, execute the program again. If you still get errors, post the issues here.
@nic335 As I said earlier, your installation is okay. The only step that remains to be checked is PHP extension build. You PHP extension build is VC11 (taken from your gist). So, download VC11 build from the link I gave in above post and install again.
Note: Uninstall old pthreads installation before trying this.
At first I was using http://windows.php.net/downloads/pecl/releases/pthreads/0.1.0/php_pthreads-0.1.0-5.5-ts-vc11-x86.zip witch I think is the correct version. I did try http://windows.php.net/downloads/pecl/releases/pthreads/0.0.45/php_pthreads-0.0.45-5.5-ts-vc11-x86.zip and still the same error. did also try http://windows.php.net/downloads/pecl/releases/pthreads/0.0.44/php_pthreads-0.0.44-5.5-ts-vc11-x86.zip
And my php installation is vc11 32 bit,
The first link you provided seems to be the right and latest pthreads release for your windows installation. Did you uninstall old pthreads dll files before continuing with the right version? What error do you get after fresh installation?
Yes. I get the same error like this issue title. But! I Think I now know why I get this error.
Take a look at my gist that I uploaded. Loaded Configuration File => C:\Program Files (x86)\PHP\php.ini
And my php installation is in my desktop in a folder called php55
So technicly it not even ptreads the extension is not even loading.
Im currently searching online on how to change that.
Perhaps you know ? :S
The config file location is a compiletime parameter. AFAIK you can't change it without recompiling
So there is no way to have multiple php version runing on the same machine ? And php installation HAVE to be at this location C:\Program Files (x86)\PHP\ ?
@nic335 I am not sure how to do that. But, you may use XAMPP package to get it work quite easily. I have got the same config like x86, VC11, windows OS etc. similar to yours. Search online for sources or use XAMPP whichever helps you.
well you can always specify the php.ini you want to use at runtime (php -c ...) , or compile PHP yourself with different locations.
Most precompiled PHP Versions I had until now had their ini in c:\php\php.ini maybe this was changed for 5.5 only. Not sure though, but I'm usualy compiling PHP myself.
@chibisuke that's very informative. nic335 may try it out.
Wow! It does work... :P All this time and it was just because of that. Thanks for your help guys!
Now I need to find an tutorial on how to compile php!
start()); ?>
Here iam getting errors like this: Fatal error: Class 'Thread' not found in C:\xampp\htdocs\search_All\thread.php on line 2.
already i Moved php_pthreads.dll to the php\ext\ directory. i Moved pthreadVC2.dll to the php\ directory.
I add this line to PHP.ini folder extension=php_pthreads.dll
even i getting problem
do you use correct PHP build? check out the post I wrote in this thread titled "PHP extension build MISMATCH" above.
Hi My PHP version 7.1 I have tried to run Thread in my web page I am getting same error message.
Fatal Error: Class 'Thread not found
Here I have followed these step
I copied php_pthreads.dll to the php\ext\ directory. Also pthreadVC2.dll to the php\ directory.
I add this line to php.ini file extension=php_pthreads.dll
@saleemkce , Thanks!!! My compiler was VC11, and then, I downloaded "php_pthreads-2.0.9-5.6-ts-vc11-x64", and worked!!
@ymotse I'm glad you got it working :)
Hi Isac,
Go to this downloads page http://windows.php.net/downloads/pecl/releases/pthreads/3.1.6/ It contains .dll file for VC14. Remove your old *vc file and replace with the file you find inside the zip directory. Make sure you choose right OS. (32-bit/64-bit).
On Tue, Dec 19, 2017 at 9:13 PM, Isac Fukushima [email protected] wrote:
@saleemkce https://github.com/saleemkce , Thanks!!! My compiler was VC11, and then, I downloaded "php_pthreads-2.0.9-5.6-ts- vc11-x64", and worked!!
How upgrade the compiler version to VC14? Thank you all!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/krakjoe/pthreads/issues/247#issuecomment-352796827, or mute the thread https://github.com/notifications/unsubscribe-auth/AGCYsKFHNYpGZbirzVHSyl8FX3Ehu1F4ks5tB9m8gaJpZM4Bl1US .
Hi I have the same fatal error (“Class Thread not found”) and although I read the above steps carefully I cannot resolve this. I did the following:
- Installed XAMPP.
When I run phpinfo() I get the following info (I also attached the full file):

PHP version 7.1.13 Compiler MSVC14 (Visual C++ 2015) Architecture x86 Thread Safety: Enabled Loaded Configuration File: c:\xampp\php\php.ini
I downloaded – I made sure that this file has the same version number (14) as my XAMPP compilation. I am using windows 7 x64 so I believe this is a proper file to use according to the description above.
From the zip I extracted :+1:
- pthreadVC2.dll to c:\xampp\php and
- php_pthreads.dld to c:\xampp\php\ext
I added the line “extension=php_pthreads.dll” to c:\xampp\php\php.ini
After all this – I still get the error. Any help will be much appreciated Thanks Giyora