Threading for PHP – Share Nothing, Do Everything 🙂

This project provides multi-threading that is compatible with PHP based on Posix Threads.


An easy to use, quick to learn Threading API for PHP5.3+
Execute any and all predefined and user declared methods and functions asynchronously
Ready made synchronization included, geared towards the PHP environment
Seamless operation in multi-threaded SAPI environments
A world of possibilities …

Technical Features

Posix Threads
Worker Threads
Synchronized Methods
Complete Support for OO – ie. traits, interfaces, inheritance
Full read/write/execute support for threaded objects
Mutex ( direct, subset )
Conditions ( direct, subset )

pthreads was written with simplicity, compatibility and efficiency in mind, it’s performance beggars belief !!


ZTS Enabled ( Thread Safety )
Posix Threads Implementation

Testing has been carried out on x86, x64 and ARM, in general you just need a compiler and pthread.h
Supported PHP Versions

pthreads should compile and work in any version of PHP from 5.3.0 to the latest release.
Windows Support

Yes !! Windows support is offered thanks to the pthread-w32 library.

Releases for Windows can be found:
Simple Windows Installation

Add pthreadVC2.dll (included with the Windows releases) to the same directory as php.exe eg. C:\xampp\php
Add php_pthreads.dll to PHP extention folder eg. C:\xampp\php\ext

Mac OSX Support

Yes !! Users of Mac will be glad to hear that pthreads is now tested on OSX as part of the development process.
Hello World

As is customary in our line of work:

class AsyncOperation extends Thread {
 public function __construct($arg) {
  $this->arg = $arg;

 public function run() {
  if($this->arg) {
   printf("Hello %s\n", $this->arg);

$thread = new AsyncOperation("World");