radebatz/preload-collector

This package is abandoned and no longer maintained. No replacement package was suggested.

Collects list of used classes to be used for PHP 7.4 preloading and provides preload script.

v1.0.0 2020-05-04 07:17 UTC

This package is auto-updated.

Last update: 2024-01-04 15:41:03 UTC


README

This library consists of two parts:

  • The collector

    Typically a middleware that, over time, builds a list of all used classes and, by default, saves this list into the file preload.json in the project root.

    Since the generated list of classes is static, it is recommended to do a fresh collection cycle after big code changes that involve a lot of new classes.

  • The preloader

    A small script which can be used as PHP 7.4 preloading script. The default filename is preload.php, also in the project root. Creation of this script is a separate step and the specific command depends on the framework used.

Supported frameworks

  • Laravel

Requirements

Installation

You can use Composer or simply Download the Release

Composer

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

composer require radebatz/preload-collector

Framework integration

Laravel

Collecting

Once installed via composer the included service provider will register a middleware to build the class list. This is an automated step and no manual configuration is required for this.

Preloading

Once the collection phase is over (the list doesn't change substantially any more), the preload script can be generated using artisan

php artisan vendor:publish "--provider=Radebatz\PreloadCollector\Laravel\ServiceProvider" --tag=preload

After this, both 'preload.php' and the generated 'preload.json' should be added to your projects repository.

Configuration

The only configuration option available is to enable/disable the collector mdidleware.

This can either be done by publishing the library config via

php artisan vendor:publish "--provider=Radebatz\PreloadCollector\Laravel\ServiceProvider" --tag=config

and editing the config in your projects config folder.

Alternatively, this may be controller via env variable like so:

export PRELOAD_COLLECTOR_ENABLED=true

Testing