PHPackages                             darkghosthunter/laraload - 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. darkghosthunter/laraload

Abandoned → [laragear/preload](/?search=laragear%2Fpreload)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

darkghosthunter/laraload
========================

Effortlessly make a Preload script for your Laravel application.

v2.3.2(4y ago)20898.7k9MITPHPPHP ^7.4.3||^8.0.2

Since Dec 27Pushed 4y agoCompare

[ Source](https://github.com/DarkGhostHunter/Laraload)[ Packagist](https://packagist.org/packages/darkghosthunter/laraload)[ Docs](https://github.com/darkghosthunter/laraload)[ Fund](https://paypal.me/darkghosthunter)[ Fund](https://ko-fi.com/DarkGhostHunter)[ RSS](/packages/darkghosthunter-laraload/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (9)Versions (16)Used By (0)

This package has been superseeded by [Laragear/Preload](https://github.com/Laragear/Preload).
---------------------------------------------------------------------------------------------

[](#this-package-has-been-superseeded-by-laragearpreload)

Please migrate to the new package.

---

Laraload
========

[](#laraload)

Effortlessly create a PHP Preload Script for your Laravel project.

Requirements
------------

[](#requirements)

- Laravel 6.x, 7.x or 8.x (Lumen *may* work too)
- PHP 7.4.3, PHP 8.0 or later
- `ext-opcache`

> The Opcache extension is not enforced by the package. Just be sure to enable it in your project's PHP main process.

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

[](#installation)

Call composer and you're done.

```
composer require darkghosthunter/laraload
```

What is Preloading? What does this?
-----------------------------------

[](#what-is-preloading-what-does-this)

Preloading is a new feature for PHP. It "compiles" a list of files into memory, thus making the application code *fast* without warming up. For that to work, it needs to read a PHP script that "uploads" these files into memory, at process startup.

This allows the first Requests to avoid cold starts, where all the scripts must be loaded by PHP at that moment. Since this step is moved to the process startup, first Requests become *faster* as all needed scripts are already in memory.

This package wraps the Preloader package that generates a preload file. Once it's generated, you can point the generated list into your `php.ini`:

```
opcache.preload = 'www/app/storage/preload.php';
```

After that, the next time PHP starts, this list of files will be preloaded.

Usage
-----

[](#usage)

By default, this package constantly recreates your preload script each 500 requests in `storage/preload.php`. That's it. But you want the details, don't you?

1. A global terminable middleware checks for non-error response.
2. Then it calls a custom *Condition* class.
3. If the *Condition* evaluates to `true`, the Preload Script is generated.
4. A `PreloadCalledEvent` is fired with the generation status.

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

[](#configuration)

Some people may not be happy with the "default" behaviour. Luckily, you can configure your own way to generate the script.

First publish the configuration file:

```
php artisan vendor:publish --provider="DarkGhostHunter\Laraload\LaraloadServiceProvider"
```

Let's check the config array:

```
