PHPackages                             bredmor/phreloader - 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. bredmor/phreloader

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

bredmor/phreloader
==================

An automatic preloader for PHP 7.4+

0.0.6(6y ago)613MITPHPPHP 7.4.0

Since Nov 26Pushed 6y ago2 watchersCompare

[ Source](https://github.com/bredmor/phreloader)[ Packagist](https://packagist.org/packages/bredmor/phreloader)[ Docs](https://github.com/bredmor/phreloader)[ RSS](/packages/bredmor-phreloader/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (5)Used By (0)

Phreloader
==========

[](#phreloader)

[![Packagist Version](https://camo.githubusercontent.com/a77ade52b7986b011f821b29ba111d3fc0d5c622ae73bf7f384b545a5b674e0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627265646d6f722f706872656c6f61646572)](https://packagist.org/packages/bredmor/phreloader) [![PHP from Packagist](https://camo.githubusercontent.com/4484e1c8dc95621722a7d60f9c7a7f2e0725fe0d0e34910a5e49329113ff4edd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f627265646d6f722f706872656c6f61646572)](https://camo.githubusercontent.com/4484e1c8dc95621722a7d60f9c7a7f2e0725fe0d0e34910a5e49329113ff4edd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f627265646d6f722f706872656c6f61646572) [![License from GitHub](https://camo.githubusercontent.com/c5bdc606b56ea3b81734a0772a3e28daf66c92a1d670718958d6dff3b4caade5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f627265646d6f722f706872656c6f61646572)](LICENSE)

Phreloader is a simple *auto-preloader* for the [PHP preloader](https://wiki.php.net/rfc/preload) available from version 7.4 and later.

This preloader will automatically preload every PHP file defined by your composer classmap, as long as it can be found within the parent directory.

Work In Progress
----------------

[](#work-in-progress)

This package is a heavy work in progress. As of the time of this writing, PHP 7.4 has not yet been released, nor has this package been extensively tested. ***USE AT YOUR OWN RISK***

This package is a stopgap solution until [Composer supports preloading](https://github.com/composer/composer/issues/7777).

### Planned Features (Not Yet Implemented)

[](#planned-features-not-yet-implemented)

- Support more custom vendor directory configurations
- Publish configured preloading script to project root
- Tests

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

[](#installation)

### From Source:

[](#from-source)

Clone the repository from GitHub or unzip into your vendor directory. Phreloader is packaged for [PSR-4](https://www.php-fig.org/psr/psr-4/) autoloading.

### From Composer:

[](#from-composer)

`composer require bredmor/phreloader`

### Basic Usage

[](#basic-usage)

Create a file `preloader.php` in your project root directory with the following contents:

```
require_once(__DIR__ . '/vendor/autoload.php');

use bredmor/phreloader/Preloader;
(new Preloader(__DIR__))->go(); // Where `__DIR__` refers to the root directory of your project's code.

```

#### Optional - Specify vendor directory location

[](#optional---specify-vendor-directory-location)

```
require_once(__DIR__ . '/vendor/autoload.php');

use bredmor/phreloader/Preloader;
(new Preloader(__DIR__, '/my/custom/vendor/dir'))->go();

```

Add the following line to your `php.ini` configuration file(s):

```
opcache.preload=/path/to/your/project/preload.php

```

That's it! The next time you restart your server, PHP will preload your project files in memory.

### Ignoring specific files or directories

[](#ignoring-specific-files-or-directories)

In the same directory as your project root, create a new file `.nopreload`. Each line in this file should be the (relative or absolute) path to files or directories not to be preloaded.

Example:

```
tests/
some_rarely_used_dir/
badfile.php
another/directory/file.php

```

Caveats
-------

[](#caveats)

- Preloading requires more available RAM the larger your project is. Preloading your entire classmap may not be desirable for larger projects, especially on smaller servers/containers. It is strongly recommended to use the ignore list to ignore rarely-loaded files, or directories that contain them..
- Because preloading stores the opcodes for your files in memory, you *must restart your server every time you change one of these files* - the new code will not be picked up until you do, your server will continue to use the version cached in RAM.

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

[](#requirements)

Phreloader is built for PHP `7.4` and later.

Authors
-------

[](#authors)

- Morgan Breden | [GitHub](https://github.com/bredmor) | [Twitter](https://twitter.com/bredmor)

Contributing
------------

[](#contributing)

Pull requests, bug reports and feature requests are welcome.

License
-------

[](#license)

Phreloader is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

2363d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8249823?v=4)[Morgan Breden](/maintainers/bredmor)[@bredmor](https://github.com/bredmor)

---

Top Contributors

[![bredmor](https://avatars.githubusercontent.com/u/8249823?v=4)](https://github.com/bredmor "bredmor (18 commits)")

---

Tags

loadingpreloaderefficiency7.4

### Embed Badge

![Health badge](/badges/bredmor-phreloader/health.svg)

```
[![Health](https://phpackages.com/badges/bredmor-phreloader/health.svg)](https://phpackages.com/packages/bredmor-phreloader)
```

###  Alternatives

[classpreloader/classpreloader

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

37642.4M32](/packages/classpreloader-classpreloader)[darkghosthunter/preloader

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

432664.1k1](/packages/darkghosthunter-preloader)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[kartik-v/yii2-widget-spinner

A widget to render animated CSS3 loading spinners with VML fallback for IE (sub repo split from yii2-widgets)

283.9M3](/packages/kartik-v-yii2-widget-spinner)[alexandre-daubois/lazy-stream

Write data to streams, only when it is really needed to.

755.7k](/packages/alexandre-daubois-lazy-stream)[classpreloader/console

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

10235.0k5](/packages/classpreloader-console)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
