0

I'm learning php-phantomjs and am gettting a Twig_Error_Runtime. Here's my 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();
    }

...and here's my .proc file:

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

What am I missing? Thanks in advance to all for any info.

VikR
  • 4,818
  • 8
  • 51
  • 96

1 Answers1

0

I got it working by replacing this:

$request->setType('phantomjsTest');

...with this:

$client->setProcedure('phantomjsTest');
VikR
  • 4,818
  • 8
  • 51
  • 96