PHPackages                             diego-ninja/preloader - 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. diego-ninja/preloader

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

diego-ninja/preloader
=====================

Preloader helper to create a PHP-ready preload script from Opcache.

v3.0.1(2y ago)5262.3k↓37.2%MITPHPPHP ^8.1

Since Apr 7Pushed 2y agoCompare

[ Source](https://github.com/diego-ninja/Preloader)[ Packagist](https://packagist.org/packages/diego-ninja/preloader)[ Docs](https://github.com/diego-ninja/preloader)[ Fund](https://paypal.me/diegorin)[ Fund](https://ko-fi.com/diegoninja)[ RSS](/packages/diego-ninja-preloader/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (15)Versions (3)Used By (0)

[![ Braden Collum - Unsplash (UL) #9HI8UJMSdZA](https://camo.githubusercontent.com/7296211ea516e55e853f3dd4ecba415df3e18dd11700a1b0e7193b1b50a7cf38/68747470733a2f2f696d616765732e756e73706c6173682e636f6d2f70686f746f2d313436313839363833363933342d6666653630376261383231313f69786c69623d72622d312e322e3126697869643d65794a6863484266615751694f6a45794d446439266175746f3d666f726d6174266669743d63726f7026773d3132383026683d34303026713d3830)](https://camo.githubusercontent.com/7296211ea516e55e853f3dd4ecba415df3e18dd11700a1b0e7193b1b50a7cf38/68747470733a2f2f696d616765732e756e73706c6173682e636f6d2f70686f746f2d313436313839363833363933342d6666653630376261383231313f69786c69623d72622d312e322e3126697869643d65794a6863484266615751694f6a45794d446439266175746f3d666f726d6174266669743d63726f7026773d3132383026683d34303026713d3830)

[![Latest Version on Packagist](https://camo.githubusercontent.com/466464ab0020a9397137f8d07c28dfc3e2a3e33fc37d39116e240aea1111b456/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646965676f2d6e696e6a612f7072656c6f616465722e7376673f7374796c653d666c6174)](https://packagist.org/packages/diego-ninja/preloader)[![Total Downloads](https://camo.githubusercontent.com/bf5c6ddec2c914b0c27cd2c85422bb2a47b202c24ccc3dc615a70be2503f2326/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646965676f2d6e696e6a612f7072656c6f616465722e7376673f7374796c653d666c617426636f6c6f723d626c7565)](https://packagist.org/packages/diego-ninja/preloader)[![PHP Version](https://camo.githubusercontent.com/6a43efc4ed05ab47c774c998393e5512550fef68194cf2cbfc83217ff16467b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646965676f2d6e696e6a612f7072656c6f616465722e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/6a43efc4ed05ab47c774c998393e5512550fef68194cf2cbfc83217ff16467b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646965676f2d6e696e6a612f7072656c6f616465722e7376673f7374796c653d666c6174)[![License](https://camo.githubusercontent.com/9ed0e42ec209c7b2931dcdaac14c7e8b2dbb7a7fb3f3fd604026a83a3adf5dfd/68747470733a2f2f706f7365722e707567782e6f72672f646965676f2d6e696e6a612f7072656c6f616465722f6c6963656e7365)](https://packagist.org/packages/darkghosthunter/preloader)[![Composer](https://github.com/diego-ninja/Preloader/workflows/PHP%20Composer/badge.svg)](https://github.com/diego-ninja/Preloader/workflows/PHP%20Composer/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/da6bcdad23b9990206bd6c5dc88772aed6889c78b4b4b1c6ce0e1ec1d6f31a6e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f646965676f2d6e696e6a612f5072656c6f616465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/diego-ninja/Preloader?branch=master)[![PHPStan Level 8](https://camo.githubusercontent.com/7ce03de83528f63d2e10e4701300f35c5bf253fc030ac0ecefa91b258b5511c0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d626c75652e737667)](https://github.com/diego-ninja/preloader/blob/main/.github/workflows/static-code-analysis.yml)

Opcache Preloader
=================

[](#opcache-preloader)

Get the best options to keep your application fast as ever, with just one line.

This package generates a [PHP preloading](https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.preload) script from your Opcache statistics automatically. No need to hack your way in. This package is a fork of [darkghosthunter/preloader](https://github.com/DarkGhostHunter/Preloader) with the only target of update code and dependencies to fit with php 8.x and Symfony 6 components. It doesn't add, at least at the moment, new functionality.

If you need php 7.4 support please, use the aforementioned package.

> If you're looking for preloading your Laravel project, check [Laragear PReload](https://github.com/Laragear/Preload).

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [How it works](#how-it-works)
- [Configuration](#configuration)
    - [Conditions](#conditions)
        - [`when()`](#when)
        - [`whenOneIn()`](#whenOneIn)
    - [Listing](#listing)
        - [`append()`](#append)
        - [`exclude()`](#exclude)
        - [`selfExclude()`](#selfexclude)
    - [Generation](#generation)
        - [`memoryLimit()`](#memorylimit)
        - [`useRequire()`](#userequire)
        - [`ignoreNotFound()`](#ignorenotfound)
    - [Compilation](#compilation)
        - [`writeTo()`](#writeto)
        - [`getList()`](#getlist)
- [Safe Preloader](#safe-preloader)
- [Example](#example)
- [Security](#security)
- [License](#license)

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

[](#requirements)

- PHP 8.1 or later.
- [Opcache &amp; Preloading enabled](https://www.php.net/manual/en/book.opcache.php) (`ext-opcache`).
- Composer Autoloader (optional).

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

[](#installation)

Require this using Composer into your project

```
composer require diego-ninja/preloader

```

> This package doesn't require `ext-opcache` to install. Just be sure to have it [enabled in your application server](https://www.php.net/manual/en/book.opcache.php).

Usage
-----

[](#usage)

Anywhere in your application, where Opcache is **enabled** and running, call `Preloader` with where to output the compiled script:

```
