PHPackages                             tristanfrn/laravel-export - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tristanfrn/laravel-export

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tristanfrn/laravel-export
=========================

Create a static site bundle from a Laravel app

0113PHP

Since Oct 12Pushed 2y agoCompare

[ Source](https://github.com/tristanfrn/laravel-export)[ Packagist](https://packagist.org/packages/tristanfrn/laravel-export)[ RSS](/packages/tristanfrn-laravel-export/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

Create a static site bundle from a Laravel app
==============================================

[](#create-a-static-site-bundle-from-a-laravel-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4b0722e5beae55a2ae9a526b800492c75cbb3e1848b7471a99ac7a3ed6ffcc87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6578706f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-export)[![Total Downloads](https://camo.githubusercontent.com/a85eb2fee796884ae060aabf6e4085b4817a16d04d7f5a5c71a52ff252d28ce7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6578706f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-export)

```
$ php artisan export
Exporting site...
Files were saved to disk `export`

```

Build your blog or site with Laravel like with the tools you're used to having and export it to be hosted statically.

Laravel Export will scan your app and create an HTML page from every URL it crawls. The entire `public` directory also gets added to the bundle so your assets are in place too.

A few example use cases for this package:

- Build your own blog or site in Laravel with all the tools you're used to using. Export a static version and just upload it anywhere for hosting, no need for managing a full-blown server anymore.
- Use something like [Nova](https://nova.laravel.com/), [Wink](https://wink.themsaid.com/), or any other admin panel to manage your site locally or on a remote server, then publish it to a service like Netlify. This gives you all benefits of a static site (speed, simple hosting, scalability) while still having a dynamic backend of some sort.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/68ed0e735c4558e31d77504e1888a24b99fc3bf98555f4a50221b002311bf430/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6578706f72742e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-export)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-export
```

After the package is installed, you can optionally publish the config file.

```
php artisan vendor:publish --provider=Spatie\\Export\\ExportServiceProvider
```

Configuration
-------------

[](#configuration)

Laravel Export doesn't require configuration to get started, but there are a few things you can tweak to your needs.

```
// config/export.php

return [
    'disk' => 'export',
];
```

This means you can also use other filesystem drivers, so you could export your site straight to something like S3.

### Determining the export contents

[](#determining-the-export-contents)

#### Crawling

[](#crawling)

With the default configuration, Laravel Export will crawl your site and export every page to a static site. If you'd like to disable this behaviour, disable the `crawl` option.

```
return [
    'crawl' => true,
];
```

#### Paths

[](#paths)

`paths` is an array of URL paths that will be exported to HTML. Use this to manually determine which pages should be exported.

```
return [
    'paths' => [
        '/',
        '/rss.xml',
    ],
];
```

#### Including files

[](#including-files)

`include_files` allows you to specify files and folders relative to the application root that should be added to the export. By default, we'll include the entire `public` folder.

```
return [
    'include_files' => [
        'public' => '',
    ],
];
```

`exclude_file_patterns` will check all source paths of included files, and exclude them if they match a pattern from in `exclude_file_patterns`. By default, all PHP files will be excluded, mainly to stop `index.php` from appearing in your export. Because the `mix-manifest.json` is no longer needed after compilation it is also excluded by default.

```
return [
    'exclude_file_patterns' => [
        '/\.php$/',
        '/mix-manifest\.json$/',
    ],
];
```

#### Configuration through code

[](#configuration-through-code)

All configuration options that affect the exports contents are also exposed in the `Exporter` class. You can inject this class to modify the export settings through code.

```
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'));
    }
}
```

### Custom disks

[](#custom-disks)

By default, Laravel Export will save the static bundle in a `dist` folder in your application root. If you want to store the site in a different folder, [configure a new disk](https://laravel.com/docs/5.8/filesystem) in `config/filesystem.php`.

```
// config/filesystem.php

return [
    'disks' => [
        //

        'export' => [
            'driver' => 'local',
            'root' => base_path('out'),
        ],
    ],
];
```

### Hooks

[](#hooks)

`before` and `after` hooks allow you to do things before or after an export. Hooks can contain any shell command.

The default configuration doesn't have any hooks configured, but shows two examples.

With this `before` hook, we'll use Yarn to build our assets before every export:

```
return [
    'before' => [
        'assets' => '/usr/local/bin/yarn production',
    ],
];
```

With this `after` hook, we'll deploy the static bundle to Netlify with their [CLI tool](https://www.netlify.com/docs/cli/) after the export.

```
return [
    'after' => [
        'deploy' => '/usr/local/bin/netlify deploy --prod',
    ],
];
```

If you want to run an export without certain hooks, use `--skip-{hook}` flags.

```
php artisan export --skip-deploy
```

To skip before, after and all hooks use the `--skip-before`, `--skip-after`, `--skip-all` flags respectively.

```
php artisan export --skip-before
```

```
php artisan export --skip-after
```

```
php artisan export --skip-all
```

Usage
-----

[](#usage)

To build a bundle, run the `export` command:

```
php artisan export
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity20

Early-stage or recently created project

 Bus Factor4

4 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7ab91de83030b8afa8b47ec6396b90d69c69df6fd60105cad86aff02f167803?d=identicon)[tristanfrn](/maintainers/tristanfrn)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (46 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (42 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (16 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (15 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (14 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![royvanv](https://avatars.githubusercontent.com/u/18717340?v=4)](https://github.com/royvanv "royvanv (10 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (9 commits)")[![nuernbergerA](https://avatars.githubusercontent.com/u/13331388?v=4)](https://github.com/nuernbergerA "nuernbergerA (7 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (4 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (3 commits)")[![rubuano](https://avatars.githubusercontent.com/u/33329579?v=4)](https://github.com/rubuano "rubuano (3 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (3 commits)")[![amitavroy](https://avatars.githubusercontent.com/u/1438890?v=4)](https://github.com/amitavroy "amitavroy (2 commits)")[![addorange](https://avatars.githubusercontent.com/u/1980618?v=4)](https://github.com/addorange "addorange (2 commits)")[![SL0wZEr](https://avatars.githubusercontent.com/u/191223?v=4)](https://github.com/SL0wZEr "SL0wZEr (1 commits)")[![alexjoffroy](https://avatars.githubusercontent.com/u/7209163?v=4)](https://github.com/alexjoffroy "alexjoffroy (1 commits)")[![alexmanase](https://avatars.githubusercontent.com/u/10696975?v=4)](https://github.com/alexmanase "alexmanase (1 commits)")[![it4need](https://avatars.githubusercontent.com/u/2446843?v=4)](https://github.com/it4need "it4need (1 commits)")

### Embed Badge

![Health badge](/badges/tristanfrn-laravel-export/health.svg)

```
[![Health](https://phpackages.com/badges/tristanfrn-laravel-export/health.svg)](https://phpackages.com/packages/tristanfrn-laravel-export)
```

###  Alternatives

[swekaj/cron-expression-generator

Generate valid cron expressions.

1069.1k1](/packages/swekaj-cron-expression-generator)[amazon/instantaccess-sdk-php

Amazon Instant Access SDK for PHP

1432.8k](/packages/amazon-instantaccess-sdk-php)[pgs-soft/hashid-bundle

Symfony Hash Id

1410.0k](/packages/pgs-soft-hashid-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
