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

ActiveLibrary

snapshotpl/preloader
====================

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

1.3.0(4y ago)05.1kMITPHPPHP ^7.4 || ^8.0

Since Dec 1Pushed 4y agoCompare

[ Source](https://github.com/snapshotpl/Preloader)[ Packagist](https://packagist.org/packages/snapshotpl/preloader)[ Docs](https://github.com/darkghosthunter/preloader)[ RSS](/packages/snapshotpl-preloader/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (1)Versions (12)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/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 7.4 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 [Laraload](https://github.com/DarkGhostHunter/Laraload).

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

[](#table-of-contents)

- [Opcache Preloader](#opcache-preloader)
    - [Installation](#installation)
    - [Usage](#usage)
    - [How it works](#how-it-works)
    - [Configuration](#configuration)
        - [`when()` (optional)](#when-optional)
            - [`whenHits()` (optional)](#whenhits-optional)
            - [`whenOneIn()` (optional)](#whenonein-optional)
        - [`memory()` (optional, default)](#memory-optional-default)
        - [`exclude()` (optional)](#exclude-optional)
        - [`append()` (optional)](#append-optional)
        - [`output()` (required)](#output-required)
        - [`overwrite()` (optional)](#overwrite-optional)
        - [`shouldCompile()|shouldRequire()` (optional)](#shouldcompileshouldrequire-optional)
        - [`generate()` (required)](#generate-required)
        - [`list()` (alternative)](#list-alternative)
    - [Give me an example](#give-me-an-example)
    - [Security](#security)
    - [License](#license)

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

[](#installation)

Require this using Composer into your project

```
composer require darkghosthunter/preloader

```

> This package doesn't requires `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 the path of your Composer Autoloader, and where to output the compiled script:

```
