spatie/laravel-export
Export a Laravel app as a static site bundle. Crawls your routes, renders HTML for each discovered URL, and copies the public directory so assets are included. Ideal for blogs and marketing sites hosted on Netlify or any static hosting.
public directory (or custom paths), ensuring assets (images, JS, CSS) are included in the export./blog/*), offering flexibility for large or small sites.spatie/crawler and Laravel’s filesystem, with no heavy external dependencies.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Dynamic Content Leaks | Risk of exporting sensitive data (e.g., auth tokens, API keys) if not filtered. | Use middleware (e.g., X-Laravel-Export header) to exclude dynamic content or pre-process routes. |
| Performance | Crawling large sites may consume significant memory/CPU. | Enable use_streaming: true in config to reduce memory usage. |
| Asset Management | Custom asset paths (e.g., Vite, Mix) may require manual configuration. | Configure include_files and exclude_file_patterns to align with build tools (e.g., exclude node_modules). |
| SEO/URL Handling | Redirects or canonical URLs may not translate perfectly to static exports. | Test with allow_redirects: true and validate URL structures post-export. |
| CI/CD Integration | Hooks (e.g., before/after) may fail in headless environments. |
Containerize builds or use lightweight hooks (e.g., yarn build). |
include_files to include compiled assets (e.g., public/build).public directory by default./blog) using paths() in config.use_streaming: true for memory efficiency.before: yarn build) to integrate with asset pipelines.php artisan export to deployment pipelines (e.g., GitHub Actions).- name: Export Static Site
run: php artisan export --skip-after
- name: Deploy to Netlify
run: netlify deploy --prod
| Component | Compatibility Notes |
|---|---|
| Laravel Versions | 7–13 (tested). |
| PHP Versions | 8.0–8.2 (as of v1.4.1). |
| Asset Tools | Works with Vite, Mix, or manual asset compilation. Exclude build artifacts (e.g., mix-manifest.json). |
| Admin Panels | Compatible with Filament, Nova, Wink (tested in examples). |
| Custom Middleware | Respects middleware during export; use X-Laravel-Export header to bypass auth for static routes. |
| Internationalization | Supports Laravel’s localization (e.g., locale() middleware). |
yarn build or npm run prod).php artisan export with configured paths/disks.config/export.php for changes (e.g., new paths or include_files).spatie/crawler.exclude_file_patterns to avoid bloating exports (e.g., debug files).php artisan export --debug for detailed crawl logs.include_files and filesystem permissions.before commands separately)./admin) to avoid confusion.paths() to specify routes.use_streaming: true and monitor PHP memory limits./blog/* and /products/* separately).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Export Fails Mid-Crawl | Partial static site. | Use --skip-all to abort gracefully; implement retry logic in CI/CD. |
| Asset Build Fails | Missing CSS/ |
How can I help you explore Laravel packages today?