在 PHP-PhantomJS 中执行 PhantomJS 程序时出错

Error when executing PhantomJS procedure in PHP-PhantomJS

我正在尝试将 PHP Phantom 与 Ubuntu 上的 Laravel 项目一起使用(php 版本 > 5.5)。按照此处提到的安装步骤进行操作:http://jonnnnyw.github.io/php-phantomjs/ .

我收到以下错误:

Error when executing PhantomJs procedure - File does not exist or is not executable: bin/phantomjs

甚至尝试使用 $client->setBinDir('/path/public/bin') 设置 bin 目录。还尝试了绝对路径和相对路径,但抛出了以下错误:

Call to undefined method JonnyW\PhantomJs\Client::setBinDir()

已尝试通过互联网找到的所有方法来解决此问题。

来自the docs

By default the PhantomJS library will look for the PhantomJS executable in the bin folder relative to where your script is running ~/bin/phantomjs. If the executable cannot be found or if the path to your PhantomJS executable differs from the default location, for example you have installed PhantomJS globally, you will need to define the path to your PhantomJS executable manually.

$client->getEngine()->setPath('/path/to/phantomjs');

请注意,您不仅要提供文件夹,还要提供 PhantomJS 二进制文件的完整路径。