wnx/sidecar-browsershot
Run Spatie Browsershot on AWS Lambda via Sidecar in Laravel—no need to install Node, Puppeteer, or Chrome on your servers. Deploy a Lambda function and generate PDFs/screenshots with headless Chrome handled remotely.
spatie/browsershot (v5+) and hammerstone/sidecar, ensuring compatibility with Laravel 10+ and PHP 8.1+. The API mirrors Browsershot, minimizing refactoring for existing codebases.hammerstone/sidecar (v3.0+), which must be configured for AWS Lambda deployments. This adds complexity but is justified by the serverless benefits.spatie/image (v3+), adding minimal overhead for advanced use cases.saveToS3) require proper IAM roles and permissions, adding operational overhead.spatie/browsershot (e.g., v4→v5) may require redeployment. The package enforces redeployment on upgrades, reducing drift risk.resources/sidecar-browsershot/fonts), which must be synced during Lambda deployments.spatie/browsershot (v5+): Core rendering logic.hammerstone/sidecar (v3.0+): Lambda orchestration.spatie/image (v3+): Optional for image manipulation.spatie/browsershot and hammerstone/sidecar (skip Chrome/Puppeteer installation).sidecar:configure).composer require wnx/sidecar-browsershot
php artisan vendor:publish --tag="sidecar-browsershot-config"
BrowsershotFunction in sidecar.php:
'functions' => [
\Wnx\SidecarBrowsershot\Functions\BrowsershotFunction::class,
],
sidecar-browsershot.php.php artisan sidecar:deploy --activate
Browsershot with BrowsershotLambda in application code:
// Before
Browsershot::url('...')->save('file.pdf');
// After
BrowsershotLambda::url('...')->save('file.pdf');
SIDECAR_BROWSERSHOT_WARMING_INSTANCES).resources/sidecar-browsershot/fonts.BrowsershotLambda replicates Browsershot's methods (e.g., url(), html(), save(), fit()), with S3-specific additions (saveToS3, readHtmlFromS3).saveToS3 requires temporary local downloads.BrowsershotLambda.spatie/browsershot upgrades (automated via Sidecar).sidecar-browsershot-layer for security patches (e.g., Chromium/Puppeteer updates).sidecar-browsershot.php reduces manual errors.SIDECAR_BROWSERSHOT_WARMING_INSTANCES) for dynamic tuning.sidecar:logs) simplifies debugging.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Lambda timeout | Incomplete PDF/image generation | Increase timeout (max 15 mins) or optimize code. |
| S3 throttling | Failed saveToS3 operations |
Implement retries with exponential backoff. |
| Cold start latency | Slow response for first requests | Enable warming or provisioned concurrency. |
| Chromium/Puppeteer crashes | Rendering failures | Monitor Lambda errors; update layers. |
| IAM permission errors | S3/Lambda access denied | Audit IAM roles; use least-privilege policies. |
How can I help you explore Laravel packages today?