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

标签 php laravel laravel-5 phantomjs php-phantomjs

我正在尝试在 Ubuntu(php 版本 > 5.5)上将 PHP Phantom 与 Laravel 项目结合使用。按照此处提到的安装步骤进行操作: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 二进制文件的完整路径。

关于php - 在 PHP-PhantomJS 中执行 PhantomJS 程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39178809/

相关文章:

Laravel 5.8 .env.testing 文件不工作

php - Laravel Passport 打印个人访问 token

php:将整个 $_POST 变量保存在 session 中

php - 时区更改 PHP/MYSQL

php - Laravel SQL : How to return 0 value if no record exists

php - 使用 PDO 将数组的日期格式更改为 MySQL 格式

php - 如何使这种关系在 MYSQL 或 Laravel 中工作

jquery - 通过比较输入名称来更改输入 css

php - SQLSTATE[22007] : Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

php - 非静态方法不应该静态调用,假设 $this 来自不兼容的上下文 -Laravel 5.2