spatie/laravel-screenshot
Driver-based Laravel package for taking web page screenshots with great defaults. Use Browsershot (Chromium) or Cloudflare Browser Rendering, customize viewport/format/quality, save to files, and easily fake/assert screenshots in tests.
Artisan commands, config()) ensures consistency with the ecosystem.Screenshot facade and binds the driver interface.config/screenshot.php file for driver-specific settings (e.g., Chromium path, Cloudflare API keys).puppeteer via Docker).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Driver Dependencies | Chromium/Cloudflare may introduce version conflicts or compatibility issues. | Use Dockerized Chromium (recommended by Spatie) or pin versions in composer.json. |
| Performance | Async jobs may fail silently or time out for complex pages. | Implement retry logic with exponential backoff; monitor queue workers. |
| Cost | Cloudflare’s pay-as-you-go model could escalate expenses. | Set budget alerts; default to Browsershot for internal use cases. |
| Scaling | Concurrent screenshot requests may overload system resources. | Use Laravel’s queue throttling; consider distributed workers (e.g., Horizon). |
| Security | Cloudflare API keys or Chromium paths may be exposed in logs/config. | Use Laravel’s env() for sensitive data; restrict IAM permissions. |
ScreenshotJob integrates natively with Laravel Queues (database, Redis, etc.).Http client for Cloudflare API calls, ensuring consistency with existing services.screenshot:test for local debugging, aligning with Laravel’s CLI tools.puppeteer, guzzlehttp, etc.spatie/browsershot package could be adapted.composer require spatie/laravel-screenshot.php artisan queue:work) and monitor job failures.Screenshot::capture()).--disable-gpu, memory limits) for production.| Component | Compatibility Notes |
|---|---|
| Laravel Queues | Works with all supported queue drivers (database, Redis, etc.). |
| Cache | Supports caching screenshots via Laravel’s cache system (e.g., Screenshot::cacheFor()). |
| Testing | Mockable drivers enable unit testing; use Screenshot::fake() for integration tests. |
| Docker | Recommended for Chromium to avoid host OS conflicts. |
| Cloud Providers | Cloudflare driver works on any Laravel-hosted environment; Chromium needs GPU access. |
config/screenshot.php.config/app.php.Screenshot::capture($url).failed_jobs table).composer update spatie/laravel-screenshot.updater to check compatibility.config/screenshot.php to avoid hardcoded values.CLOUDFLARE_API_TOKEN).libx11).screenshot:test command for local validation.queue:failed table for job inspection.How can I help you explore Laravel packages today?