Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sidecar Browsershot Laravel Package

wnx/sidecar-browsershot

Run Spatie Browsershot on AWS Lambda via Sidecar for Laravel. Generate PDFs/screenshots without installing Node, Puppeteer, or Chrome on your server—headless Chrome runs in a deployed Lambda function. Includes config publishing and Sidecar deploy steps.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Cost Optimization: Offloads resource-intensive PDF/image generation (e.g., Browsershot) from servers to AWS Lambda, reducing EC2 costs and infrastructure complexity.
  • Scalability: Enables horizontal scaling for high-volume rendering tasks (e.g., batch PDF generation, dynamic reports) without server bottlenecks.
  • Feature Roadmap:
    • Serverless PDF Generation: Replace legacy cron jobs or self-hosted solutions (e.g., wkhtmltopdf) with a managed, pay-per-use model.
    • Dynamic Content Export: Support features like "Export to PDF" for user-generated content (e.g., dashboards, invoices) without blocking UI threads.
    • Multi-Format Output: Standardize on a single tool for images (PNG/JPG), PDFs, and HTML snapshots across the product.
  • Build vs. Buy:
    • Buy: Avoid maintaining Chromium/Puppeteer infrastructure (e.g., Docker containers, CI/CD for updates).
    • Customize: Extend with custom fonts, S3 integration, or warming strategies without vendor lock-in (MIT license).
  • Use Cases:
    • E-Commerce: Generate product catalog PDFs or receipts at scale.
    • SaaS: Automate compliance reports (e.g., GDPR data exports) as serverless functions.
    • Media: Process screenshots for social sharing or analytics (e.g., A/B testing).
    • Legacy Migration: Replace deprecated tools (e.g., wkhtmltopdf) with modern, maintained alternatives.

When to Consider This Package

Adopt This Package If:

  • AWS Lambda is already in use: Leverage existing Sidecar setup for consistency (avoids managing separate Lambda functions).
  • Rendering is sporadic or unpredictable: Pay-per-use model is cheaper than always-on servers for low-to-moderate volume.
  • Need S3 integration: Directly save outputs to S3 (bypassing Lambda response size limits).
  • Custom fonts or Chromium tweaks: Support for custom fonts and fine-grained control over rendering (e.g., window size, emoji rendering).
  • Laravel ecosystem: Minimal friction with Spatie’s Browsershot and Sidecar compatibility.
  • Cost-sensitive scaling: Avoid over-provisioning servers for peak loads (e.g., Black Friday PDF generation).

Look Elsewhere If:

  • High-frequency, low-latency needs: Lambda cold starts (~100ms–2s) may impact UX for real-time previews.
  • Large payloads: Inputs >6MB may hit Lambda limits (use S3 workarounds instead).
  • Non-AWS environments: Requires AWS Lambda (though Sidecar supports other providers via adapters).
  • Legacy PHP/Laravel: Dropped support for PHP <8.2 or Laravel <11 (check changelog).
  • Advanced debugging: Limited visibility into Chromium logs compared to self-hosted solutions.
  • Offline/air-gapped: Requires AWS connectivity.

How to Pitch It (Stakeholders)

For Executives:

"Serverless PDF/Image Generation to Cut Cloud Costs by 60%+ This package moves heavy lifting—like converting web pages to PDFs or high-res images—from always-on servers to AWS Lambda, paying only for usage. For example:

  • E-commerce: Generate 10,000 receipts/month for ~$50 (vs. $200+ on EC2).
  • SaaS: Eliminate cron jobs and server spikes during report generation.
  • Scalability: Handle 10x traffic during promotions without hiring DevOps.

Why now?

  • No infrastructure: No Chrome/Puppeteer maintenance or updates.
  • Future-proof: Built on Spatie’s battle-tested Browsershot (used by 100K+ apps).
  • AWS-native: Integrates seamlessly with our existing Sidecar setup.

Risk: Minimal—MIT-licensed, actively maintained, and tested in production by Stefan Zweifel (Laravel core contributor)."


For Engineering:

"Leverage Sidecar to Offload Browsershot to Lambda Problem: Self-hosted Browsershot (Chromium/Puppeteer) requires:

  • Server resources (CPU/RAM).
  • Maintenance (updates, security patches).
  • Scaling headaches for spikes.

Solution: Use wnx/sidecar-browsershot to:

  1. Replace local Browsershot with a Lambda-backed BrowsershotLambda facade (drop-in API).
  2. Avoid Node/Chrome: No local dependencies—Lambda handles the heavy lifting.
  3. Scale effortlessly: Lambda auto-scales; Sidecar manages retries and warming.
  4. Optimize costs:
    • S3 integration: Bypass Lambda response limits for large files.
    • Warming: Pre-instantiate Lambdas to reduce cold starts (configurable via .env).
  5. Extend functionality:
    • Custom fonts (drop into resources/sidecar-browsershot/fonts).
    • Image manipulation (requires spatie/image).
    • Direct S3 saves (avoid local storage).

Implementation:

composer require wnx/sidecar-browsershot hammerstone/sidecar spatie/browsershot
php artisan vendor:publish --tag="sidecar-browsershot-config"
# Update sidecar.php to include BrowsershotFunction
php artisan sidecar:deploy --activate

Usage (identical to Spatie’s Browsershot):

BrowsershotLambda::url('https://example.com')->save('invoice.pdf');
BrowsershotLambda::html('<h1>Hello</h1>')->saveToS3('report.pdf');

Trade-offs:

  • Cold starts: Mitigate with warming (e.g., SIDECAR_BROWSERSHOT_WARMING_INSTANCES=3).
  • Debugging: Limited logs; use Sidecar’s monitoring tools.
  • Vendor lock-in: MIT license, but AWS-specific.

Next Steps:

  1. Pilot: Test with a non-critical feature (e.g., admin PDF exports).
  2. Benchmark: Compare Lambda costs vs. current EC2 usage.
  3. Document: Update runbooks for Sidecar/Lambda management."
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope