0

我正在学习 php-phantomjs 并且正在学习 Twig_Error_Runtime。这是我的PHP:

    $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);

我错过了什么?提前感谢所有人提供的任何信息。

4

1 回答 1

0

我通过替换它来工作:

$request->setType('phantomjsTest');

...有了这个:

$client->setProcedure('phantomjsTest');
于 2017-03-04T18:02:10.740 回答