php-phantomjs: Problems with executing in windows environment
Hello,
I encountered an error when executing my codes in XAMPP (Windows) enviornment, while there was no error at all on my ubuntu.
The error was like this:
Uncaught exception 'JonnyW\PhantomJs\Exception\ProcedureFailedException' with message 'Error when executing PhantomJs procedure "default" - File does not exist or is not executable:
C:/xampp/htdocs/phantom/bin/phantomloader' in C:\xampp\htdocs\phantom\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Procedure\Procedure.php:132 Stack trace: #0
C:\xampp\htdocs\phantom\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Client.php(171): JonnyW\PhantomJs\Procedure\Procedure->run(Object(JonnyW\PhantomJs\Client), Object(JonnyW\PhantomJs\Message\Request), Object(JonnyW\PhantomJs\Message\Response)) #1
C:\xampp\htdocs\phantom\functions_new.php(20): JonnyW\PhantomJs\Client->send(Object(JonnyW\PhantomJs\Message\Request), Object(JonnyW\PhantomJs\Message\Response)) #2 C:\xampp\htdocs\phantom\oneitem_ky.php(174): argos('012/803') #3 {main} thrown in C:\xampp\htdocs\phantom\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Procedure\Procedure.php on line 132
What I did:
- Used composer to install the dependencies
- Changed Client.php under vender\jonnyw\php-phantomjs\src\JonnyW\PhantomJs line 110, the value of $this->phantomJs = ‘C:/xampp/htdocs/phantom/bin/phantomjs.exe’;
- Changed Client.php under vender\jonnyw\php-phantomjs\src\JonnyW\PhantomJs line 111, the value of $this->phantomLoader = ‘C:/xampp/htdocs/phantom/bin/phantomloader’;
I also tried changing $this->phantomLoader = ‘C:/xampp/htdocs/phantom/bin/phantomloader.bat’, but still did not work out.
Any ideas?
Thanks.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 30 (3 by maintainers)
This is a pretty straightforward bug, that can be fixed easily. With composer, you can use the following workaround (on Windows) in the meantime:
try this one on windows:
vendor/…/PhantomJs/Client.php
update getCommand() to public function getCommand() { $phantomJs = $this->getPhantomJs(); $phantomLoader = $this->getPhantomLoader();
Your test.php file
require_once(‘vendor/autoload.php’);//make sure this path is correct use JonnyW\PhantomJs\Client;
$client = Client::getInstance(); $client->setPhantomJs(DIR.‘/bin/phantomjs.exe’); // DIR is needed