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

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

darkghosthunter/preloader
=========================

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

v2.2.0(5y ago)434681.7k↓63.5%23[3 issues](https://github.com/DarkGhostHunter/Preloader/issues)[6 PRs](https://github.com/DarkGhostHunter/Preloader/pulls)1MITPHPPHP ^7.4||^8.0

Since Dec 1Pushed 2y ago15 watchersCompare

[ Source](https://github.com/DarkGhostHunter/Preloader)[ Packagist](https://packagist.org/packages/darkghosthunter/preloader)[ Docs](https://github.com/darkghosthunter/preloader)[ Fund](https://paypal.me/darkghosthunter)[ Fund](https://ko-fi.com/DarkGhostHunter)[ RSS](/packages/darkghosthunter-preloader/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (20)Used By (1)

[![ 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/102f77fd1d0ebcca8884bd00a03541a732337a68c02ce9040f26da246f343b85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461726b67686f737468756e7465722f7072656c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/darkghosthunter/preloader) [![License](https://camo.githubusercontent.com/fcdf03be01562477e3f7af3ed70ae1ee00f6c87b6f1d67e4d48a478d64162085/68747470733a2f2f706f7365722e707567782e6f72672f6461726b67686f737468756e7465722f7072656c6f616465722f6c6963656e7365)](https://packagist.org/packages/darkghosthunter/preloader)[![](https://camo.githubusercontent.com/c3388bda16019b1929ad15fd165cf42b2e148bffe49565c95d33a8406ad15d5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461726b67686f737468756e7465722f7072656c6f616465722e737667)](https://camo.githubusercontent.com/c3388bda16019b1929ad15fd165cf42b2e148bffe49565c95d33a8406ad15d5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6461726b67686f737468756e7465722f7072656c6f616465722e737667)[![](https://github.com/DarkGhostHunter/Preloader/workflows/PHP%20Composer/badge.svg)](https://github.com/DarkGhostHunter/Preloader/workflows/PHP%20Composer/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/5bcdcda38455e03026ccd57f9768e58203ac9adb5ff06c6310ce75f28668b42b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4461726b47686f737448756e7465722f5072656c6f616465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/DarkGhostHunter/Preloader?branch=master)

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.

> 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 7.4.3, PHP 8.0 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 darkghosthunter/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:

```
