1. Go to this page and download the library: Download wnx/sidecar-browsershot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wnx / sidecar-browsershot example snippets
/*
* All of your function classes that you'd like to deploy go here.
*/
'functions' => [
\Wnx\SidecarBrowsershot\Functions\BrowsershotFunction::class,
],
use Wnx\SidecarBrowsershot\BrowsershotLambda;
// an image will be saved
BrowsershotLambda::url('https://example.com')->save($pathToImage);
// a pdf will be saved
BrowsershotLambda::url('https://example.com')->save('example.pdf');
// save your own HTML to a PDF
BrowsershotLambda::html('<h1>Hello world!!</h1>')->save('example.pdf');
// Get HTML of a URL and store it on a given disk
$html = BrowsershotLambda::url('https://example.com')->bodyHtml();
Storage::disk('s3')->put('example.html', $html);
use Wnx\SidecarBrowsershot\BrowsershotLambda;
// Use an HTML file from S3 to generate a PDF
BrowsershotLambda::readHtmlFromS3('html/example.html')->save('example.pdf');
// You can also pass a disk name if
use Wnx\SidecarBrowsershot\BrowsershotLambda;
// an image will be saved on S3
BrowsershotLambda::url('https://example.com')->saveToS3('example.jpg');
// a pdf will be saved on S3
BrowsershotLambda::url('https://example.com')->saveToS3('example.pdf');
// save your own html to a PDF on S3
BrowsershotLambda::html('<h1>Hello world!!</h1>')->saveToS3('example.pdf', 'example-store');
// Take screenshot at 1920x1080 and scale it down to fit 200x200
BrowsershotLambda::url('https://example.com')
->windowSize(1920, 1080)
->fit(\Spatie\Image\Enums\Fit::Contain, 200, 200)
->save('example.jpg');
// Take screenshot at 1920x1080 and scale it down to fit 200x200 and save it on S3
// Note: To do the image manipulation, BrowsershotLambda will download the image
// from S3 to the local disc of your app, manipulate it and then upload it back to S3.
BrowsershotLambda::url('https://example.com')
->windowSize(1920, 1080)
->fit(\Spatie\Image\Enums\Fit::Contain, 200, 200)
->saveToS3('example.jpg');