### Install Laravel Export Package via Composer Source: https://github.com/spatie/laravel-export/blob/main/README.md This Composer command adds the `spatie/laravel-export` package to your Laravel project's dependencies. Running this command downloads and installs the package, making its functionalities available for use. ```bash composer require spatie/laravel-export ``` -------------------------------- ### Publish Laravel Export Configuration File Source: https://github.com/spatie/laravel-export/blob/main/README.md After installing the package, this Artisan command publishes the default configuration file (`export.php`) to your application's `config` directory. This allows you to customize the package's behavior, such as the output disk or crawling settings. ```bash php artisan vendor:publish --provider=Spatie\\Export\\ExportServiceProvider ``` -------------------------------- ### Run Laravel export command Source: https://github.com/spatie/laravel-export/blob/main/README.md This Bash command demonstrates the basic usage of the `php artisan export` command to build a static bundle using the Laravel Export package. It initiates the export process, including any configured hooks. ```bash php artisan export ``` -------------------------------- ### Configure PHP `before` hook for asset building Source: https://github.com/spatie/laravel-export/blob/main/README.md This PHP configuration snippet demonstrates how to define a `before` hook that executes a shell command (e.g., `yarn production`) before the export process begins. This is useful for tasks like compiling assets or preparing the environment. ```php return [ 'before' => [ 'assets' => '/usr/local/bin/yarn production', ], ]; ``` -------------------------------- ### Configure PHP `after` hook for Netlify deployment Source: https://github.com/spatie/laravel-export/blob/main/README.md This PHP configuration snippet shows how to define an `after` hook that runs a shell command (e.g., `netlify deploy --prod`) after the export process completes. This can be used for post-export actions like deploying the generated static bundle to a hosting service. ```php return [ 'after' => [ 'deploy' => '/usr/local/bin/netlify deploy --prod', ], ]; ``` -------------------------------- ### Skip all hooks during Laravel export Source: https://github.com/spatie/laravel-export/blob/main/README.md This Bash command shows how to use the `--skip-all` flag with `php artisan export` to prevent both `before` and `after` hooks from executing during the export process. This provides a quick way to run an export without any custom hook interference. ```bash php artisan export --skip-all ``` -------------------------------- ### Run Composer tests for Laravel Export package Source: https://github.com/spatie/laravel-export/blob/main/README.md This Bash command executes the test suite for the Laravel Export package using Composer. It's typically used by developers to verify functionality and ensure code quality. ```bash composer test ``` -------------------------------- ### Run Laravel Export Artisan Command Source: https://github.com/spatie/laravel-export/blob/main/README.md This command initiates the static site export process for your Laravel application. It crawls the configured URLs and saves the generated static files to the specified filesystem disk, typically in a `dist` folder. ```bash $ php artisan export Exporting site... Files were saved to disk `export` ``` -------------------------------- ### Skip `before` hooks during Laravel export Source: https://github.com/spatie/laravel-export/blob/main/README.md This Bash command shows how to use the `--skip-before` flag with `php artisan export` to prevent all `before` hooks from executing during the export process. This is useful when you want to bypass pre-export tasks. ```bash php artisan export --skip-before ``` -------------------------------- ### Skip specific `after` hook during Laravel export Source: https://github.com/spatie/laravel-export/blob/main/README.md This Bash command demonstrates how to use the `--skip-{hook}` flag with `php artisan export` to prevent a specific `after` hook (e.g., `deploy`) from executing during the export process. This provides fine-grained control over which hooks run. ```bash php artisan export --skip-deploy ``` -------------------------------- ### Skip `after` hooks during Laravel export Source: https://github.com/spatie/laravel-export/blob/main/README.md This Bash command shows how to use the `--skip-after` flag with `php artisan export` to prevent all `after` hooks from executing during the export process. This is useful when you want to bypass post-export tasks. ```bash php artisan export --skip-after ``` -------------------------------- ### Configure Export Disk in Laravel Export Source: https://github.com/spatie/laravel-export/blob/main/README.md This PHP snippet from `config/export.php` demonstrates how to specify the filesystem disk where the static site bundle will be saved. By default, it uses a disk named 'export', which can be configured in `config/filesystem.php` to point to a specific directory or cloud storage. ```php // config/export.php return [ 'disk' => 'export', ]; ``` -------------------------------- ### Configure Custom Filesystem Disk for Laravel Export Source: https://github.com/spatie/laravel-export/blob/main/README.md This PHP snippet shows how to define a custom filesystem disk named 'export' in your `config/filesystem.php`. This allows Laravel Export to save the static bundle to a specific directory, such as `base_path('out')`, providing flexibility over the output location. ```php // config/filesystem.php return [ 'disks' => [ // 'export' => [ 'driver' => 'local', 'root' => base_path('out'), ], ], ]; ``` -------------------------------- ### Programmatically Configure Laravel Export in Service Provider Source: https://github.com/spatie/laravel-export/blob/main/README.md This PHP code demonstrates how to dynamically configure Laravel Export within a Laravel Service Provider's `boot` method. By injecting the `Exporter` class, you can programmatically control settings like crawling behavior and define export paths based on application logic, such as database records. ```php use Illuminate\Support\ServiceProvider; use Spatie\Export\Exporter; class AppServiceProvider extends ServiceProvider { public function boot(Exporter $exporter) { $exporter->crawl(false); $exporter->paths(['', 'about', 'contact', 'posts']); $exporter->paths(Post::all()->pluck('slug')); } } ``` -------------------------------- ### Configure Files to Include in Laravel Export Source: https://github.com/spatie/laravel-export/blob/main/README.md The `include_files` option in `config/export.php` specifies files and folders, relative to the application root, that should be added to the static export bundle. By default, the entire `public` folder is included to ensure assets are present. ```php return [ 'include_files' => [ 'public' => '', ], ]; ``` -------------------------------- ### Define File Exclusion Patterns for Laravel Export Source: https://github.com/spatie/laravel-export/blob/main/README.md The `exclude_file_patterns` array in `config/export.php` allows defining regular expression patterns to exclude specific files from the static site export. This prevents unwanted files, such as PHP scripts or build manifests, from being included in the final bundle. ```php return [ 'exclude_file_patterns' => [ '/\\.php$/', '/mix-manifest\\.json$/', ], ]; ``` -------------------------------- ### Define Specific Paths for Laravel Export Source: https://github.com/spatie/laravel-export/blob/main/README.md The `paths` array in `config/export.php` allows you to manually specify an array of URL paths that Laravel Export should export to HTML. This is useful for precise control over which pages are included, especially when crawling is disabled or insufficient. ```php return [ 'paths' => [ '/', '/rss.xml', ], ]; ``` -------------------------------- ### Enable/Disable Site Crawling in Laravel Export Source: https://github.com/spatie/laravel-export/blob/main/README.md This configuration option in `config/export.php` controls whether Laravel Export should automatically crawl your site to discover and export pages. Setting `crawl` to `false` disables this behavior, requiring you to manually specify paths for export. ```php return [ 'crawl' => true, ]; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.