Xampp install pthreads for Php

1. Check the runtime enviroment

  • php version
D:\xampp\php>php -v
PHP 5.6.34 (cli) (built: Jul 18 2013 10:56:37)

The php of xampp is 32-bit by default.

  • windows version

It determines the location of "pthreadVC2.dll".

2. Download the file

File url : http://windows.php.net/downloads/pecl/releases/pthreads/

Download php_pthreads-2.0.9-5.6-ts-vc11-x86.zip according to the above version.

3. Install

  • Copy "pthreadVC2.dll" to "D:\xampp\php\"
  • Copy "php_pthreads.dll" to "D:\xampp\php\ext\"
  • Add "extension=php_pthread.dll" to "php.ini"
  • Add "LoadFile D:/xampp/php/pthreadVC2.dll" to "httpd.conf"
  • Restart Apache

4. Test

Official test code:

<?php
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");
if($thread->start())
  $thread->join();
?>

If it has error, you can use the following command to check it out.

D:\xampp\php>php -m

You can make sure if the pthreads module have been loaded.

results matching ""

    No results matching ""