Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open 'none' - Screenshot output #118

Open
sdkcarlos opened this issue Sep 7, 2016 · 0 comments
Open

Can't open 'none' - Screenshot output #118

sdkcarlos opened this issue Sep 7, 2016 · 0 comments

Comments

@sdkcarlos
Copy link

sdkcarlos commented Sep 7, 2016

Hi, i'm new with this library and i'm trying to create a simple screenshot of the google website.

I'm using Symfony 3, here's my controller.

<?php

namespace sandboxBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use JonnyW\PhantomJs\Client;

class DefaultController extends Controller
{
    public function indexAction()
    {
        $client = Client::getInstance();

        $client->getEngine()->setPath('C:\\Users\\sdkca\\Desktop\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe');

        // In windows, phantomjs starts sometimes an infinite loop,to prevent that
        // Set proxy-type to none to make it work
        $client->getEngine()->setOptions(array(
            'proxy-type' => 'none'
        ));

        $width  = 800;
        $height = 600;
        $top    = 0;
        $left   = 0;

        $webPath = $this->container->getParameter('kernel.root_dir') . '/../web/';

        /** 
         * @see JonnyW\PhantomJs\Http\CaptureRequest
         **/
        $request = $client->getMessageFactory()->createCaptureRequest('https://www.google.de', 'GET');
        $request->setOutputFile($webPath.'screenshot.jpg');
        $request->setViewportSize($width, $height);
        $request->setCaptureDimensions($width, $height, $top, $left);
        $request->setTimeout(5000);

        /** 
         * @see JonnyW\PhantomJs\Http\Response 
         **/
        $response = $client->getMessageFactory()->createResponse();

        // Send the request
        $client->send($request, $response);

        echo $client->getLog(); // Output log

        return $this->render('sandboxBundle:Default:template.html.twig', array(

        ));
    }
}

I think everything is in order, however the image isn't created and the log only outputs :

Can't open 'none'

Basically, the error comes when i try to set proxy to none in the options. I need to start phantomjs with the --proxy-type=none parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant