PHP pthreads: Fatal error: Class 'Thread' not found

前端 未结 6 1479
小蘑菇
小蘑菇 2020-12-06 05:28

I use php5.5 on my webserver. Now I want to use pthreads. Here\'s my php config: http://dd19010.kasserver.com/infophp.php55

After implementing this code.....

相关标签:
6条回答
  • 2020-12-06 05:46

    Hi I encountered this problem and managed to solve it.

    First, consider the VC version of your PHP and the VC version of extension. In mine I attached the extension pthreads.dll with version VC14 from http://windows.php.net/downloads/pecl/releases/pthreads/ but my PHP VC version is VC11. Look for the lower version to match with the VC version of your PHP.

    Second, maybe you missed the step #3 at PHP page. It states that you need to copy the pthreadVC2.dll to different folder. Here's the full instruction.

    1. Find out what is your 'PHP Extension Build' version by using phpinfo(). You can use this - http://localhost/?phpinfo=1

    2. Download the pthreads that matches your php version (32 bit or 64 bit) and php extension build (currently used VC11). Use this link for download - http://windows.php.net/downloads/pecl/releases/pthreads/

    3. Extract the zip - Move php_pthreads.dll to the 'bin\php\ext\' directory. Move pthreadVC2.dll to the 'bin\php\' directory. Move pthreadVC2.dll to the 'bin\apache\bin' directory. Move pthreadVC2.dll to the 'C:\windows\system32' directory.

    4. Open php\php.ini and add extension=php_pthreads.dll

    Reference: https://secure.php.net/manual/en/pthreads.installation.php

    0 讨论(0)
  • 2020-12-06 05:46

    By default Threads are not implemented in PHP, and according to your phpinfo it does not seem to be loaded. Check out the PHP manual on how to set-up/configure the module.

    0 讨论(0)
  • 2020-12-06 05:48

    Your phpinfo shows that you have php with thread safety disabled. You need to install a version of php that is thread safe to use pthreads. This may or may not fix your current issue though.

    You may need to copy the pthreadsVC2.dll into the bin directory of your web service as well.

    /etc/php55/fpm/
    

    You're looking for the folder with php.ini in it.

    Make sure the php.ini file has the line added:

    extension=php_pthreads.dll
    
    0 讨论(0)
  • 2020-12-06 05:50

    I think you need to include the extensions int he php.ini file, because I can't see it in the config. You can see that each library has its own section like MySQL, but there isn't such for the threads. I haven't used threads ever but that should be a good place to start from.

    0 讨论(0)
  • 2020-12-06 05:57

    I am using WAMP and found that the pthreadVC2.dll should go to the Apache folder instead:

    C:\wamp\bin\apache\apache2.4.9\bin

    Unlike what is written in README.md, you don't need to have it in the PHP folder, but the php_pthreads.dll should still go to:

    C:\wamp\bin\php\php5.5.12\ext

    After this, search in this file:

    C:\wamp\bin\apache\apache2.4.9\bin\php.ini

    For ;extension=php_pgsql.dll and add extension=php_pthreads.dll in a new line after it (yes, it's the bin\php.ini in the Apache folder, not the one in the PHP folder).

    Exit WAMP and start it again. You should now see in WAMP menu under PHP > PHP extensions, the new php_pthreads extension.

    0 讨论(0)
  • 2020-12-06 05:58

    1) Create one php file
    phpinfo(); --> Run
    Example: Info
    PHP Version: 5.6.31
    Compiler: MSVC11 (Visual C++ 2012)
    Architecture: x64

    2)Go to website:
    http://windows.php.net/downloads/pecl/releases/pthreads/
    Example 2.0.9 file
    Compiler:VC11
    Architecture:x64
    php_pthreads-2.0.9-5.6-ts-vc11-x64.zip download.

    3)Extract php_pthreads.dll and pthreadVC2.dll.
    wamp\bin\php\php5.6.31\ext\ --> copy php_pthreads.dll
    wamp\bin\php\php5.6.31\ --> copy pthreadVC2.dll
    wamp\bin\apache\apache2.4.27\bin --> copy pthreadVC2.dll

    4)Now edit php.ini
    wamp\bin\apache\apache2.4.27\bin\php.ini\ --> Add extension=php_pthreads.dll
    wamp\bin\php\php5.6.31\php.ini\ --> Add extension=php_pthreads.dll

    5)Now Restart Wamp

    0 讨论(0)
提交回复
热议问题