Php-phantomjs with Laravel (File does not exist or is not executable: bin/phantomjs) Php-phantomjs with Laravel (File does not exist or is not executable: bin/phantomjs) laravel laravel

Php-phantomjs with Laravel (File does not exist or is not executable: bin/phantomjs)


Well, have a look at the video here:https://www.youtube.com/watch?v=unLTKz9Jqyw

This guy explains all the stuff you might need. Hope that helps.

EDIT:

Try putting this code...

<?php//test.php$phantom_loc = "C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\web-optimization\phantomjs4\src\bin\phantomjs.exe";$dir = "C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\web-optimization\phantomjs4\src\bin\\";//Is dir executable$dir_is_Writeable = @file_exists($dir . ".");if ($dir_is_Writeable === true) {    echo "$dir is writable";} else {    echo "$dir is not writable";}echo "<br><br>";//is executableif(is_executable($phantom_loc)) {    echo ("$phantom_loc is executable");} else {    echo ("$phantom_loc is not executable");}echo "<br><br>";//Jonnywrequire 'vendor/autoload.php';use JonnyW\PhantomJs\Client;$client = Client::getInstance();$client->setBinDir('C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\web-optimization\phantomjs4\src\bin\\');$client->setPhantomJs('phantomjs.exe');var_dump($client->getCommand());


Maybe for someone, it will be helpful. The new version of Php-phantomjs(4.*) has no methods:

$client->setBinDir('absolute_path/bin');$client->setPhantomJs('phantomjs.exe');

So, instead of it, you can use that:

$client->getEngine()->setPath('absolute_path/bin/phantomjs.exe');


FWIW I just installed this on a very quick test project and it worked fine with only one small tweak.

I added the following to my composer.json file as per the instructions:

"require": {    "jonnyw/php-phantomjs": "~3.0"},"config": {    "bin-dir": "bin"},"scripts": {    "post-install-cmd": [        "PhantomInstaller\\Installer::installPhantomJS"    ],    "post-update-cmd": [        "PhantomInstaller\\Installer::installPhantomJS"    ]}

Then composer install will install the library and then install phantomjs afterwards.

Then I copied and pasted the top example from http://jonnnnyw.github.io/php-phantomjs/usage.html#basic-request into index.php (after requiring Composer's autoloader).

All I then had to do (because I'm in the UK) was remove the response status if (as I get a 301) to make the Google homepage show.

Now this was on a Mac but I can't imagine it being any different on Centos.

Then, putting my index.php file inside a subdirectory public, as you would have in a Laravel install, all I had to do was add the following line after Client::getInstance():

$client->setBinDir('../bin');

Then it worked again.

Obviously this is not a full Laravel install, but it does mimic the environment alright. One thing I did notice was that changing the bin-dir in composer.json does not always fully update the files that get put in bin. As such, I had to rm -rf bin vendor and then composer update again to ensure I had a fresh installation of composer and its packages.