2015-10-18 51 views
2

我試圖使用PhantomJS,這是我的代碼:
不能使用PHP-Phantomjs

<?php 
    require '../../../../vendor/autoload.php'; 

    use JonnyW\PhantomJs\Client; 

    $client = Client::getInstance(); 

    $request = $client->getMessageFactory()->createRequest(); 
    $response = $client->getMessageFactory()->createResponse(); 

    $request->setMethod('GET'); 
    $request->setUrl('http://google.com'); 

    $client->send($request, $response); 

    var_dump($response); 
?> 

但它給我這個錯誤:

Fatal error: Uncaught exception 'JonnyW\PhantomJs\Exception\ProcedureFailedException' with message 'Error when executing PhantomJs procedure "default" - File does not exist or is not executable: bin/phantomjs' in /var/www/html/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php:132 Stack trace: #0 /var/www/html/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Client.php(170): JonnyW\PhantomJs\Procedure\Procedure->run(Object(JonnyW\PhantomJs\Client), Object(JonnyW\PhantomJs\Message\Request), Object(JonnyW\PhantomJs\Message\Response)) #1 /var/www/html/vendor/jonnyw/php-phantomjs/examples/basic-request.php(15): JonnyW\PhantomJs\Client->send(Object(JonnyW\PhantomJs\Message\Request), Object(JonnyW\PhantomJs\Message\Response)) #2 {main} thrown in /var/www/html/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php on line 132 

所以它的崩潰在此行:

$client->send($request, $response); 

我嘗試了chmod 777所有\供應商董事y和兒童,但不改變任何東西,你有想法嗎?

回答

-1

好吧,我只需添加鏈接到目錄,這是在我的項目的根目錄。

+0

請問您具體嗎?因爲我面臨着和你一樣的問題。請幫幫我。 – asubanovsky

+0

@asubanovsky,不幸的是我發佈了這個(很久)的時間。如果我記得,vendor/autoload.php是在bin目錄中嗎?如果是這樣,請嘗試將bin路徑放在require行(如果我記得)。 –