title: How Do I load pthreads extension in CLI?
body: <p>I have built both php and Apache from source on MAC OSX 10.11.</p>
  
  <p>I have been having trouble loading pthreads extension in CLI.. I misunderstood how to load it and now I do not truly understand what should I do.</p>
  
  <p>Here is what I have done so far.</p>
  
  <p>I configured php with the following command:</p>
  
  <pre><code>'./configure' 
  '--prefix=/Users/username/Terminal/WebServer'
  '--with-apxs2=/Users/username/Terminal/WebServer/bin/apxs'
  '--enable-maintainer-zts' 
  '--enable-pthreads=shared' 
  '--enable-debug' 
  '--with-tsrm-pthreads' 
  '--with-config-file-path=/Users/username/Terminal/WebServer/ini' 
  '--enable-cli'
  </code></pre>
  
  <p>Apache's loaded Modules:</p>
  
  <pre><code>Compiled in modules:
    core.c
    mod_so.c
    http_core.c
    worker.c
  </code></pre>
  
  <p>So,  in /Users/username/Terminal/WebServer/ini directory I created <code>php-cli.ini</code> file and added <code>extension=pthreads.so</code> line, then I ran <code>php -m</code> command, the following is the output:</p>
  
  <pre><code>[PHP Modules]
  Core
  ctype
  date
  dom
  fileinfo
  filter
  hash
  iconv
  json
  libxml
  pcre
  PDO
  pdo_sqlite
  Phar
  posix
  &lt;strong&gt;pthreads&lt;/strong&gt;
  Reflection
  session
  SimpleXML
  SPL
  sqlite3
  standard
  tokenizer
  xml
  xmlreader
  xmlwriter
  
  [Zend Modules]
  </code></pre>
  
  <p>I restarted Apache and opened <code>index.php</code> file which has <code>phpinfo()</code> in it.<br>
  <strong>Notable information</strong> </p>
  
  <p><code>Configuration File (php.ini) Path => /Users/username/Terminal/WebServer/ini</code><br>
  <code>Loaded Configuration File => /Users/username/Terminal/WebServer/ini/php.ini</code><br>
  <code>Scan this dir for additional .ini files => (none)</code><br>
  <code>Additional .ini files parsed => (none)</code><br>
  <code>Thread Safety => Enabled</code><br></p>
  
  <p><code>phpinfo()</code> doens't include pthreads module information and I don't know whether it should or not.<br>
  at this point I open test.php file which includes the following pthreads script:<br></p>
  
  <pre><code>&lt;?php $thread = new class extends Thread {
      public function run() {
          echo "Hello World\n";
      }
  };
  
  $thread-&gt;start() &amp;&amp; $thread-&gt;join();
  ?&gt;
  </code></pre>
  
  <p>and the output through apache is:<br></p>
  
  <p><code>Fatal error: Class 'Thread' not found in /Users/username/Sites/test.php on line 1</code></p>
  
  <p><br></p>
  
  <p>When I run the following command on Terminal<br>
  <code>$ php /Users/username/Sites/test.php</code></p>
  
  <p>The output is : <strong>Hello World</strong></p>
  
  <p><strong>So the question is</strong> how do I load pthreads extension in CLI properly ?</p>