- How does this package solve Chromium’s limitations in AWS Lambda?
- This package offloads Browsershot rendering to a Sidecar container running alongside your Lambda, bypassing Lambda’s 15-minute timeout and memory constraints. The Sidecar handles Chromium’s heavy lifting independently, while your Lambda remains lightweight for orchestration.
- Can I use this with Laravel 7 or PHP 7.4?
- No, this package requires Laravel 8+ and PHP 8.0+ due to Sidecar’s AWS SDK dependencies. If you’re on an older stack, consider alternatives like Puppeteer Cloud or pre-rendering with CloudFront.
- Do I need to install Chrome or Puppeteer locally?
- No, this package abstracts Chromium entirely—it runs only in the Sidecar container on AWS Lambda. You’ll skip Chrome/Puppeteer installation in your Laravel app, but the Sidecar must have Chromium pre-installed in its Docker image.
- How do I handle PDFs or screenshots larger than Lambda’s /tmp storage?
- Store outputs directly in S3 or EFS. The package supports streaming files to cloud storage, avoiding Lambda’s ephemeral storage limits. Configure the `storage` option in the published config to point to your preferred backend.
- Will this work with existing spatie/browsershot code?
- Yes, the package wraps Browsershot’s API seamlessly. Replace `Browsershot::html()` with `BrowsershotLaravel::html()`—the rest of your code (e.g., PDF margins, formats) remains unchanged. Just ensure you’ve published the config and deployed the Sidecar.
- What’s the performance impact of using Sidecar vs. running Chromium locally?
- Sidecar adds ~100–500ms latency for inter-process communication (IPC) between Lambda and the container. However, it eliminates cold starts and memory constraints, making it faster for long-running tasks (e.g., complex PDFs or SPAs) in serverless environments.
- How do I debug issues if the Sidecar fails to render?
- Enable AWS CloudWatch Logs for both Lambda and Sidecar. Use the `sidecar:logs` Artisan command to inspect Sidecar output. For Chromium-specific errors, check the Sidecar’s Docker logs or adjust its memory limits in the Lambda configuration.
- Can I use this with other Laravel PDF packages like laravel-dompdf?
- No, this package is specifically for `spatie/browsershot`. If you’re using `laravel-dompdf`, consider alternatives like AWS Textract or third-party APIs, as dompdf uses a different rendering engine (HTML5Lib) and isn’t compatible with Sidecar’s Chromium-based approach.
- What’s the cost difference vs. running Browsershot on EC2 or a server?
- Sidecar on Lambda can be cheaper for sporadic usage, as you pay per invocation rather than idle server costs. However, frequent Sidecar calls (e.g., per-user PDFs) may incur higher costs due to Lambda’s pricing model. Compare with pre-rendering (e.g., CloudFront) or batch processing.
- How do I scale this for high traffic (e.g., 1000+ concurrent requests)?
- Use Lambda concurrency limits to throttle requests and deploy Sidecar as a Fargate task for better scalability. Alternatively, implement a queue (SQS) to batch requests and reduce Sidecar load. Monitor with CloudWatch and adjust memory/CPU allocations as needed.