我试图使用PHP PhantomJS加载一个页面,但是我得到了错误。
Fatal error: Uncaught JonnyW\PhantomJs\Exception\ProcedureFailedException: Error when executing PhantomJs procedure - File does not exist or is not executable: bin/phantomjs in /Volumes/WWW ROOT/namechase/www/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php:138
Stack trace:
#0 /Volumes/WWW ROOT/namechase/www/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Client.php(162): JonnyW\PhantomJs\Procedure\Procedure->run(Object(JonnyW\PhantomJs\Http\Request), Object(JonnyW\PhantomJs\Http\Response))
#1 /Volumes/WWW ROOT/namechase/www/crawling.php(30): JonnyW\PhantomJs\Client->send(Object(JonnyW\PhantomJs\Http\Request), Object(JonnyW\PhantomJs\Http\Response))
#2 {main}
thrown in /Volumes/WWW ROOT/namechase/www/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php on line 138这只发生在我的一个测试域,而不是另一个。
我在这两个域上运行的代码是相同的,但是不能在两个测试床中的一个上工作。两者都运行在同一台机器上,只使用不同的虚拟主机,但只有一台返回错误。
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
echo '<pre>';
use JonnyW\PhantomJs\Client;
$client = Client::getInstance();
$delay = 5; // 5 seconds
$request = $client->getMessageFactory()->createRequest('https://google.com', 'GET');
$request->setDelay($delay);
/**
* @see JonnyW\PhantomJs\Http\Response
**/
$response = $client->getMessageFactory()->createResponse();
// Send the request
$client->send($request, $response);
if($response->getStatus() === 200) {
// Dump the requested page content
echo $response->getContent();
}我尝试在phantomjs文件中设置到composer.json文件的路径
"config": {
"bin-dir": "/usr/local/bin"
}但这似乎没什么区别
发布于 2016-07-07 22:42:55
当您运行Composer安装包时,PhantomJS脚本将获取PhantomJS并将其安装到项目的/bin文件夹中。
它永远不会降落在/usr/local/bin,除非你手动安装或移动到那里。
您将得到以下错误消息:File does not exist or is not executable: bin/phantomjs。
首先,我将检查该文件是否被正确获取并安装到bin文件夹中。(如果文件未安装到项目的bin文件夹中,那么安装程序脚本将在Composer运行期间给出一个错误。)
其次,我会检查文件权限。通常情况下,安装程序会处理这个问题,但如果设置了可执行标记+x,只需查看一下即可执行标志。
https://stackoverflow.com/questions/37889081
复制相似问题