PHPackages                             wnx/sidecar-browsershot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wnx/sidecar-browsershot

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wnx/sidecar-browsershot
=======================

A Sidecar function to run Browsershot on Lambda.

v2.9.0(2mo ago)2331.5M—5.9%35[6 issues](https://github.com/stefanzweifel/sidecar-browsershot/issues)[1 PRs](https://github.com/stefanzweifel/sidecar-browsershot/pulls)4MITPHPPHP ^8.4CI passing

Since Feb 13Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/stefanzweifel/sidecar-browsershot)[ Packagist](https://packagist.org/packages/wnx/sidecar-browsershot)[ Docs](https://github.com/stefanzweifel/sidecar-browsershot)[ GitHub Sponsors](https://github.com/stefanzweifel)[ RSS](/packages/wnx-sidecar-browsershot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (32)Versions (45)Used By (4)

Run Browsershot on AWS Lambda with Sidecar for Laravel
======================================================

[](#run-browsershot-on-aws-lambda-with-sidecar-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7499ad7d4284aeeac59facae6d039e7443edb27404cb5929653338746d089c4c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776e782f736964656361722d62726f7773657273686f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wnx/sidecar-browsershot)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7a458760532c021345c1f07ffc4b2d3ded8c53cdd9878b1a74e4b0a21362ae2e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73746566616e7a77656966656c2f736964656361722d62726f7773657273686f742f72756e2d74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/stefanzweifel/sidecar-browsershot/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/23ba717ebff9ef973d257052c3394b5a8e7e07f3355d9fa74f9e12bc428b3cd8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73746566616e7a77656966656c2f736964656361722d62726f7773657273686f742f6c61726176656c2d70696e742d66697865722e796d6c3f6c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/stefanzweifel/sidecar-browsershot/actions?query=workflow%3A%22Laravel+Pint%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6cf9bb6f59b4edc5770a4c262ec084a9a7252fe4e4b1b91b0920014ce0bd9ccc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776e782f736964656361722d62726f7773657273686f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wnx/sidecar-browsershot)

This package allows you to run [Browsershot](https://github.com/spatie/browsershot) on [AWS Lambda](https://aws.amazon.com/lambda/) through [Sidecar](https://github.com/hammerstonedev/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
------------

[](#requirements)

This package requires that [`spatie/browsershot`](https://github.com/spatie/browsershot) and [`hammerstone/sidecar`](https://github.com/hammerstonedev/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
------------

[](#installation)

You can install the package via composer:

```
composer require wnx/sidecar-browsershot
```

You can publish the config file with:

```
php artisan vendor:publish --tag="sidecar-browsershot-config"
```

Register the `BrowsershotFunction::class` in your `sidecar.php` config file.

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

Deploy the Lambda function by running:

```
php artisan sidecar:deploy --activate
```

See [Sidecar documentation](https://hammerstone.dev/sidecar/docs/main/functions/deploying) for details.

Note

You should redeploy the Lambda function, whenever you upgrade `spatie/browsershot`.

Usage
-----

[](#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`.

```
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('Hello world!!')->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);
```

Warming
-------

[](#warming)

sidecar-browsershot supports [warming](https://hammerstone.dev/sidecar/docs/main/functions/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.

```
SIDECAR_BROWSERSHOT_WARMING_INSTANCES=5
```

Alternatively you can publish the `sidecar-browsershot.php` config file and change the `warming` setting yourself.

Reading source from S3
----------------------

[](#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.

```
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 required (default: 's3')
BrowsershotLambda::readHtmlFromS3('html/example.html', 's3files')->save('example.pdf');
```

Saving directly to S3
---------------------

[](#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

```
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('Hello world!!')->saveToS3('example.pdf', 'example-store');
```

Image Manipulation
------------------

[](#image-manipulation)

Like the original Browsershot package, you can [manipulate the image](https://spatie.be/docs/browsershot/v4/usage/creating-images#content-sizing-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 using `fit()` in combination with `saveToS3`, the image will be downloaded from S3 to your local disc, manipulated and then uploaded back to S3.

```
// 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');
```

Register Custom Fonts
---------------------

[](#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
-------

[](#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](https://aws.amazon.com/).

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)

```
cp testbench.example.yaml testbench.yaml
cp .env.example .env
./vendor/bin/testbench sidecar:configure
```

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.

```
./vendor/bin/testbench sidecar-browsershot:setup
```

After the successful deployment, you can run the testsuite.

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stefan Zweifel](https://github.com/stefanzweifel)
- [Aaron Francis](https://github.com/aarondfrancis)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity59

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 67.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~43 days

Total

43

Last Release

66d ago

Major Versions

v0.2.0 → v1.0.02022-03-06

v1.13.1 → v2.0.02023-12-30

PHP version history (3 changes)v0.1.0PHP ^8.0

v2.0.0PHP ^8.2

v2.6.1PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6e76cb0a5ed6788731857a8b4e1a27e283cef831fe42bf9636549bf9b35ddd7?d=identicon)[stefanzweifel](/maintainers/stefanzweifel)

---

Top Contributors

[![stefanzweifel](https://avatars.githubusercontent.com/u/1080923?v=4)](https://github.com/stefanzweifel "stefanzweifel (129 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (24 commits)")[![marksalmon](https://avatars.githubusercontent.com/u/7000886?v=4)](https://github.com/marksalmon "marksalmon (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![robgaskell](https://avatars.githubusercontent.com/u/43436841?v=4)](https://github.com/robgaskell "robgaskell (4 commits)")[![bryanjamesmiller](https://avatars.githubusercontent.com/u/8781182?v=4)](https://github.com/bryanjamesmiller "bryanjamesmiller (2 commits)")[![jrslv](https://avatars.githubusercontent.com/u/873324?v=4)](https://github.com/jrslv "jrslv (1 commits)")[![Loots-it](https://avatars.githubusercontent.com/u/73197182?v=4)](https://github.com/Loots-it "Loots-it (1 commits)")[![orkhanahmadov](https://avatars.githubusercontent.com/u/7041590?v=4)](https://github.com/orkhanahmadov "orkhanahmadov (1 commits)")[![osbre](https://avatars.githubusercontent.com/u/23292709?v=4)](https://github.com/osbre "osbre (1 commits)")[![princejohnsantillan](https://avatars.githubusercontent.com/u/60916966?v=4)](https://github.com/princejohnsantillan "princejohnsantillan (1 commits)")[![Silver343](https://avatars.githubusercontent.com/u/51054165?v=4)](https://github.com/Silver343 "Silver343 (1 commits)")[![simaodiascosta](https://avatars.githubusercontent.com/u/46888903?v=4)](https://github.com/simaodiascosta "simaodiascosta (1 commits)")[![aarondfrancis](https://avatars.githubusercontent.com/u/881931?v=4)](https://github.com/aarondfrancis "aarondfrancis (1 commits)")[![yoeriboven](https://avatars.githubusercontent.com/u/4047804?v=4)](https://github.com/yoeriboven "yoeriboven (1 commits)")[![Admiral-Enigma](https://avatars.githubusercontent.com/u/13486531?v=4)](https://github.com/Admiral-Enigma "Admiral-Enigma (1 commits)")[![ahinkle](https://avatars.githubusercontent.com/u/17038330?v=4)](https://github.com/ahinkle "ahinkle (1 commits)")[![dbpolito](https://avatars.githubusercontent.com/u/347400?v=4)](https://github.com/dbpolito "dbpolito (1 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (1 commits)")[![Jamesking56](https://avatars.githubusercontent.com/u/253237?v=4)](https://github.com/Jamesking56 "Jamesking56 (1 commits)")

---

Tags

awslambdalaravellaravel-packagepuppeteerlaravellambdabrowsershotwnxsidecarsidecar-browsershot

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/wnx-sidecar-browsershot/health.svg)

```
[![Health](https://phpackages.com/badges/wnx-sidecar-browsershot/health.svg)](https://phpackages.com/packages/wnx-sidecar-browsershot)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
