2017-03-03 43 views
0

我正在學習php-phantomjs並且正在獲取Twig_Error_Runtime。這是我的PHP:PHP-PhantomJS:Twig_Error_Runtime?

$location = '/Applications/myWebApp/js/phantomjsTest.proc'; 
    $serviceContainer = ServiceContainer::getInstance(); 

    $procedureLoader = $serviceContainer->get('procedure_loader_factory') 
      ->createProcedureLoader($location); 
    $client->getProcedureLoader()->addLoader($procedureLoader); 

    $request = $client->getMessageFactory()->createRequest(); 
    $request->setType('phantomjsTest'); 

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

    if ($response->getStatus() === 200) { 
     // Dump the requested page content 
     echo $response->getContent(); 
    } 

...這是我的.PROC文件:

phantom.onError = function (msg, trace) { 
    console.log(JSON.stringify({ 
     "status": msg 
    })); 
    phantom.exit(1); 
}; 

var system = require('system'); 
var uri = "http://www.jonnyw.me"; 

var page = require('webpage').create(); 
page.open(uri, function (status) { 
    console.log(JSON.stringify({ 
     "status": status 
    })); 

    if (status === "success") { 
     page.render('example.png'); 
    } 
    phantom.exit(1); 
}); 

phantom.exit(1); 

我缺少什麼?在此先感謝任何信息。

回答

0

我得到它的工作通過更換此:

$request->setType('phantomjsTest'); 

...這一點:

$client->setProcedure('phantomjsTest');