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

Laravel Export Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Static Site Generation (SSG) Use Case: The package is a perfect fit for Laravel applications requiring static exports (e.g., blogs, marketing sites, or documentation). It leverages Laravel’s routing, middleware, and Blade templating while generating static HTML, CSS, and JS files.
  • Hybrid Dynamic/Static Workflows: Ideal for projects using Laravel as a CMS (e.g., with Filament, Nova, or Wink) but needing static hosting (e.g., Netlify, Vercel, or S3). The package preserves dynamic backend logic while enabling static frontend delivery.
  • Asset Inclusion: Automatically bundles the public directory (or custom paths), ensuring assets (images, JS, CSS) are included in the export.
  • Crawling vs. Manual Paths: Supports both automated crawling (discovering all routes) and explicit path definitions (e.g., /blog/*), offering flexibility for large or small sites.

Integration Feasibility

  • Laravel-Centric: Designed for Laravel (v7–13), with minimal friction for existing projects. No major architectural changes required.
  • Middleware & Routing Compatibility: Respects Laravel’s middleware stack (e.g., auth, localization) during export, ensuring static pages reflect dynamic behavior.
  • Blade Support: Renders Blade templates to static HTML, preserving Laravel’s templating logic.
  • Dependency Lightweight: Relies on spatie/crawler and Laravel’s filesystem, with no heavy external dependencies.

Technical Risk

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).

Key Questions for TPM

  1. Use Case Clarity:
    • Is the primary goal static hosting (e.g., Netlify) or backup/archival of dynamic content?
    • Are there dynamic elements (e.g., user-specific content) that must be excluded?
  2. Scalability:
    • What is the estimated size of the exported site (e.g., 100 pages vs. 10,000)?
    • Will exports run in CI/CD (e.g., GitHub Actions) or on-demand?
  3. Asset Pipeline:
    • How are assets built (e.g., Vite, Laravel Mix)? Are there custom paths or hashing to configure?
  4. Deployment Workflow:
    • Will exports trigger automated deployments (e.g., Netlify CLI) or require manual uploads?
    • Are there rollback mechanisms for failed exports?
  5. Maintenance:
    • Who will monitor export failures (e.g., broken links, missing assets)?
    • How will content updates (e.g., new blog posts) be reflected in static exports?

Integration Approach

Stack Fit

  • Laravel Core: Fully compatible with Laravel’s routing, middleware, and Blade. No framework modifications needed.
  • Asset Build Tools:
    • Vite/Laravel Mix: Configure include_files to include compiled assets (e.g., public/build).
    • Static Assets: Automatically includes the public directory by default.
  • Hosting Providers:
    • Static Hosts: Netlify, Vercel, Cloudflare Pages, S3.
    • Dynamic Backends: Retain Laravel for admin panels (e.g., Filament) while serving static content.
  • Database:
    • Exports are static snapshots; dynamic data (e.g., user sessions) is excluded unless explicitly included.

Migration Path

  1. Pilot Phase:
    • Start with a subset of routes (e.g., /blog) using paths() in config.
    • Test with use_streaming: true for memory efficiency.
  2. Full Integration:
    • Replace dynamic hosting with static exports for non-sensitive routes.
    • Use hooks (e.g., before: yarn build) to integrate with asset pipelines.
  3. CI/CD Automation:
    • Add php artisan export to deployment pipelines (e.g., GitHub Actions).
    • Example workflow:
      - name: Export Static Site
        run: php artisan export --skip-after
      - name: Deploy to Netlify
        run: netlify deploy --prod
      

Compatibility

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).

Sequencing

  1. Pre-Export:
    • Build assets (yarn build or npm run prod).
    • Pre-warm routes (e.g., cache dynamic data if needed).
  2. Export:
    • Run php artisan export with configured paths/disks.
    • Validate output for broken links/missing assets.
  3. Post-Export:
    • Deploy static files to hosting provider.
    • Update DNS/CDN if switching from dynamic hosting.

Operational Impact

Maintenance

  • Configuration Drift:
    • Monitor config/export.php for changes (e.g., new paths or include_files).
    • Use feature flags to toggle exports during development.
  • Dependency Updates:
    • Laravel/PHP version compatibility is well-maintained (see changelog).
    • Watch for breaking changes in spatie/crawler.
  • Asset Management:
    • Regularly audit exclude_file_patterns to avoid bloating exports (e.g., debug files).

Support

  • Troubleshooting:
    • Broken Links: Use php artisan export --debug for detailed crawl logs.
    • Missing Assets: Verify include_files and filesystem permissions.
    • Hook Failures: Isolate hooks (e.g., test before commands separately).
  • Documentation:
    • Maintain a runbook for common issues (e.g., "Export fails on large sites → enable streaming").
    • Document excluded routes (e.g., /admin) to avoid confusion.
  • Stakeholder Communication:
    • Clarify that exports are static snapshots (not real-time).
    • Define SLA for exports (e.g., "Exports must complete within 10 minutes for sites <500 pages").

Scaling

  • Performance Bottlenecks:
    • Crawling: Disable for large sites; use paths() to specify routes.
    • Memory: Enable use_streaming: true and monitor PHP memory limits.
    • Disk I/O: Use fast storage (e.g., SSD) or remote disks (e.g., S3) for large exports.
  • Parallelization:
    • For monolithic exports, consider splitting routes (e.g., /blog/* and /products/* separately).
    • Use queue workers for post-export tasks (e.g., deployments).
  • Incremental Exports:
    • No built-in incremental support; full exports required on changes.
    • Mitigation: Use atomic deployments (e.g., Netlify’s redirect rules) to minimize downtime.

Failure Modes

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/
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata