skip to Main Content

new php parallel. it’s new and there is no troubleshooting about it anywhere and the only documentation about it, is php.net itself which is not enough.

this is what I did (per instructions):

  • installed latest version of WAMP(3.1.9 x64).
  • installed latest version of PHP(7.3.9) on WAMP.
  • added PHP to windows system environment path.
  • added pthreadVC2.dll to PHP folder & added pthreadVC2.dll to windows system environment path.
  • added php_parallel.dll to php/ext directory.
  • added extension=parallel to php.ini.
  • restarted everything.
<?php
# this is my code
$runtime = new parallelRuntime();

$future = $runtime->run(function(){
    for ($i = 0; $i < 50; $i++)
        echo "$i";
        
    return "easy";
});

for ($i = 0; $i < 50; $i++) {
    echo ".";
}

hours spent. now windows cmd says:
"Fatal error: Uncaught Error: Class ‘parallelRuntime’ not found in …[my file address]"
and wampserver says "The connection was reset (firefox error)" only on the page I use parallelRuntime and the other pages work fine.
and please with all do respect don’t mark my question as broad one or any other things if you simply don’t know the answer. at least show me some links.

4

Answers


  1. As far as I can tell, to install an extension from a .dll provided by PECL, the following need to match between your extension and your PHP build, found in phpinfo():

    1. PHP Version: Found in PHP Version
    2. Thread Safe: Found in PHP Extension Build (TS=threadsafe or NTS=not-threadsafe)
    3. Compiler Version: Found in PHP Extension Build (eg: VS15 or VS16)
    4. x86 vs x64: Found in Architecture

    On the PECL repository for parallel, you should check latest updated version and the package names are self-explanatory, so you can choose your desired one, i.e. ... 7.3-ts-vc15-x64


    Note (maybe does not apply now):
    Given the limited builds of parallel, your PHP Build must be: 7.3+, TS, and VC15. Double-check that this is indeed the case for you by looking at your phpinfo(), and also be sure you are using the x64 version (since you said your PHP is x64).

    Login or Signup to reply.
  2. Error log turned out the saver.

    PHP Startup: Failed to load .../php/php7.4.9/ext/pthreadVC2, The system cannot find the file ..
    

    Then I’ve just removed .dll from file name, and then it gave:

    PHP Startup: Invalid library (maybe not a PHP library) 'pthreadVC2' in Unknown on line 0
    

    If I remember correctly, it turned out that WampServer (with it’s builtin php) does not support multi-threading/safe-threading or like that, and it was not possible to use it on WampServer. However interesting thing turned out, is that it works in CLI.

    Login or Signup to reply.
  3. I had the exact same issue. Also, I copied the file pthreadVC2.dll into the folder ext. When I moved this file out of the folder then it has worked fine.

    Folders:

    • yourPhpFolder/pthreadVC2.dll
    • yourPhpFolder/ext/php_parallel.dll
    Login or Signup to reply.
  4. The correct answer is JS_Riddler’s post (Dated Dec 3 ’19 and edited by T.Todua), but I wanted to elaborate for Windows users.

    Before you install, on the command line, if you do "php -v", you may see something like:

    PHP 7.3.33 (cli) (built: Nov 16 2021 14:49:44) ( ZTS MSVC15 (Visual C++ 2017) x64 )

    Don’t let the "(Visual C++ 2017)" confuse you…it’s the "ZTS MSVC15" that is important, indicating the thread-safe build and runtime library.

    Also note the major and minor version numbers: "7.3" in the above example. The build number (eg the third number, ’33’ in the example) does not matter.

    And also note the architecture: "x64" in the example.

    The major version, minor version, and architecture need to match the version of parallel you download, so for the above example you would want to download

    php_parallel-1.1.4-7.3-ts-vc15-x64.zip

    Note: after downloading and unzipping the parallel archive:

    1. copy the php_parallel.dll file to php/ext/php_parallel.dll
    2. copy the pthreadsVC2.dll to php/pthreadsVC2.dll
    3. add "extension=parallel" somewhere in your php.ini on a line by itself.

    you should be able to run "php -v" from a command line. If you get an error, double check that the php.exe (and pthreadsVC2.dll) are on your PATH and that the php_parallel.dll version you have in the php/ext folder matches the major and minor versions of your php executable.

    Another note: Many hosting companies do not use the ZTS version of php, so it appears this extension is mostly for CLI development applications at this time. Don’t try to write production code that relies on it unless you know your target host supports it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search