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

Help - Integration With Laravel Job #88

Open
ivan-grozni opened this issue Apr 19, 2017 · 4 comments
Open

Help - Integration With Laravel Job #88

ivan-grozni opened this issue Apr 19, 2017 · 4 comments

Comments

@ivan-grozni
Copy link

I'm looking to integrate this with a laravel install that requires a login, but any time I try to take a snapshot of a laravel-generated URL, the image won't save out (but the job does save out). For example,
I have a dispatched event handling the request:

public function handle(){   
        $fileName = $this->component->entity_id."_".date("Y-m-d").'.jpg';

        //take screenshot
        $fileLocation = storage_path()."/app/tmp/".$fileName;
        $screenCapture = new Capture(route("admin.components.preview", $this->component->id));
        //$screenCapture = new Capture("http://google.com"); // this works!

        $screenCapture->jobs->setLocation(storage_path().'/app/weber-screens/');
        $screenCapture->setTimeout(5000);
        $screenCapture->setWidth(1400);

        if($screenCapture->save($fileLocation)){ //returns false unless using Google's URL
            
            //upload screenshot to s3
            $s3 = \Storage::disk('s3');
            $dir = "/screens/";
            $filePath = $dir. $fileName;
            $thumbPath = $dir."/thumbs" . $fileName;
            $s3->put($filePath, file_get_contents($screenCapture->getImageLocation()), 'public');
    
            //delete temp file
            unlink ( $fileLocation );
    
            return true;
        }
    }

Using the laravel route, I don't get any file saved out (screenCapture->save() returns false). But if I go to the job saved out, copy the command, and run it manually in the CLI it saves out correctly.

@peter-mw
Copy link
Contributor

peter-mw commented Apr 19, 2017

Hi, seems your route cannot be opened from cli

you must give a valid address which is reachable over internet

your "route" maybe is producing unreachable URL when you run it from the command line

the capture script spawns a new process and it does not know about laravel

try to see what your route outputs to other CLI programs

for example try

exec("curl ".route("admin.components.preview", $this->component->id))." ")

and see if there is any output

@ivan-grozni
Copy link
Author

ivan-grozni commented Apr 19, 2017 via email

@peter-mw
Copy link
Contributor

hi, another guess maybe check if the files in the bin folder are executable

maybe make chmod +x on the files in the bin folder and try again

@brianwfl88
Copy link

You must set the url of your application in order to use the route in laravel jobs.

Find the setting in app config and replace the appropriate url

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

3 participants