Download the PHP package wnx/sidecar-browsershot without Composer
On this page you can find all versions of the php package wnx/sidecar-browsershot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wnx/sidecar-browsershot
More information about wnx/sidecar-browsershot
Files in wnx/sidecar-browsershot
Package sidecar-browsershot
Short Description A Sidecar function to run Browsershot on Lambda.
License MIT
Homepage https://github.com/stefanzweifel/sidecar-browsershot
Informations about the package sidecar-browsershot
Run Browsershot on AWS Lambda with Sidecar for Laravel
This package allows you to run Browsershot on AWS Lambda through Sidecar.
You won't need to install Node, Puppeteer or Google Chrome on your server. The heavy lifting of booting a headless Google Chrome instance is happening on AWS Lambda.
Requirements
This package requires that spatie/browsershot
and hammerstone/sidecar
have been installed in your Laravel application.
Follow their installation and configuration instructions. (You can skip the installation of puppeteer and Google Chrome for Browsershot though.)
Installation
You can install the package via composer:
You can publish the config file with:
Register the BrowsershotFunction::class
in your sidecar.php
config file.
Deploy the Lambda function by running:
See Sidecar documentation for details.
[!Note] You should redeploy the Lambda function, whenever you upgrade
spatie/browsershot
.
Usage
You can use BrowsershotLambda
like the default Browsershot
-class coming from the Spatie package.
All you need to do is replace Browsershot
with BrowsershotLambda
.
Warming
sidecar-browsershot supports warming for faster execution.
To enable this feature set the SIDECAR_BROWSERSHOT_WARMING_INSTANCES
variable in your .env
to the desired number of instances Sidecar should warm for you.
Alternatively you can publish the sidecar-browsershot.php
config file and change the warming
setting yourself.
Reading source from S3
You can store an HTML file on AWS S3 and pass the path to Lambda for it to create the PDF or image from. This is necessary for large source files in order to avoid restrictions on the size of Lambda requests.
Saving directly to S3
You can store your file directly on AWS S3 if you want to keep it there, or to avoid the size limit on Lambda responses.
You just need to pass a path and optional disk name (default: 's3') to the saveToS3
method.
- You must have an S3 disk defined in config/filesystems.php
- You must give S3 write permissions to your sidecar-execution-role
Image Manipulation
Like the original Browsershot package, you can manipulate the image size and format.
To perform image manipulations on the screenshot, you need to install the optional dependency spatie/image
. v3 or higher is required.
Note
If you're usingfit()
in combination withsaveToS3
, the image will be downloaded from S3 to your local disc, manipulated and then uploaded back to S3.
Register Custom Fonts
By default, sidecar-browsershot includes the "Noto Color Emoji"-font, to ensure that emojis are rendered correctly.
If you want to use custom fonts, you can put them all into a resources/sidecar-browsershot/fonts
-folder. (You can customize the location of that folder in the sidecar-browsershot.fonts
config)
sidecar-browsershot will include all files in that folder when deploying the Lambda function and will register them automatically in Chromium for you.
Testing
The testsuite makes connections to AWS and runs the deployed Lambda function. In order to run the testsuite, you will need an active AWS account.
We can use the native sidecar:configure
artisan command to create the necessary AWS credentials for Sidecar. First copy the testbench.example.yaml
file to testbench.yaml
.
Then run ./vendor/bin/testbench sidecar:configure
to start the Sidecar setup process. (You only have to do the setup once)
After finishing the Sidecar setup process, you will have received a couple of SIDECAR_*
environment variables. Add these credentials to .env
.
Now we can deploy our local BrowsershotFunction
to AWS Lambda. Run the following command in your terminal, before executing the testsuite.
After the successful deployment, you can run the testsuite.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Stefan Zweifel
- Aaron Francis
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of sidecar-browsershot with dependencies
hammerstone/sidecar Version ^0.4 || ^0.5 || ^0.6
illuminate/contracts Version ^10.0 || ^11.0
spatie/browsershot Version ^4.0 || ^5.0
spatie/laravel-package-tools Version ^1.9.2