PHP code example of hcancelik / sidecar-browsershot

1. Go to this page and download the library: Download hcancelik/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/ */

    

hcancelik / sidecar-browsershot example snippets


/*
 * All of your function classes that you'd like to deploy go here.
 */
'functions' => [
    \Hcancelik\SidecarBrowsershot\Functions\BrowsershotFunction::class,
],

use Hcancelik\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 Hcancelik\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');
shell
php artisan sidecar:deploy --activate