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
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()
:PHP Version
PHP Extension Build
(TS=threadsafe or NTS=not-threadsafe)PHP Extension Build
(eg: VS15 or VS16)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 yourphpinfo()
, and also be sure you are using thex64
version (since you said your PHP is x64).Error log turned out the saver.
Then I’ve just removed .dll from file name, and then it gave:
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.
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:
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:
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.