Collects list of used classes to be used for PHP 7.4 preloading and provides preload script.
This library consists of two parts:
Typically a middleware that, over time, builds a list of all used classes and, by default, saves this list into the file
preload.jsonin 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.
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.
You can use Composer or simply Download the Release
Once composer is installed, execute the following command in your project root to install this library:
composer require radebatz/preload-collector
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.
Once the collection phase is over (the list doesn't change substantially any more), the preload script can be generated
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.
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
Alternatively, this may be controller via
env variable like so: