PHPackages                             cnizzardini/cakephp-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. [CLI &amp; Console](/categories/cli)
4. /
5. cnizzardini/cakephp-preloader

ActiveCakephp-plugin[CLI &amp; Console](/categories/cli)

cnizzardini/cakephp-preloader
=============================

OPCache Preloader plugin for CakePHP

v1.0.2(3mo ago)1234.4k↓13.1%3MITPHPPHP ^8.1CI passing

Since May 15Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/cnizzardini/cakephp-preloader)[ Packagist](https://packagist.org/packages/cnizzardini/cakephp-preloader)[ RSS](/packages/cnizzardini-cakephp-preloader/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (14)Used By (0)

CakePHP Preloader
=================

[](#cakephp-preloader)

[![Latest Version on Packagist](https://camo.githubusercontent.com/84294117e5f2d5f69c9cbedeb952a6322622ce27655980161528d54300ff27b7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636e697a7a617264696e692f63616b657068702d7072656c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cnizzardini/cakephp-preloader)[![Build](https://github.com/cnizzardini/cakephp-preloader/actions/workflows/merge.yml/badge.svg)](https://github.com/cnizzardini/cakephp-preloader/actions/workflows/merge.yml)[![Coverage Status](https://camo.githubusercontent.com/a4062e4685b3df67c04ae233a009e89f1d80c53b742a7bb4f6bed1cbf79a5d8e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f636e697a7a617264696e692f63616b657068702d7072656c6f616465722f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/cnizzardini/cakephp-preloader?branch=main)[![License: MIT](https://camo.githubusercontent.com/27d0eb762f0a2e9efc3b528a37b55ac9adcdac612990a4f1cd1077564b2d9846/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d6d69742d626c7565)](LICENSE.md)[![CakePHP](https://camo.githubusercontent.com/be71b0dd29f1024dc31e09a537d8633461e770d73e9deac28c2c42cce002ff37/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63616b657068702d253545352e302d7265643f6c6f676f3d63616b65706870)](https://book.cakephp.org/4/en/index.html)[![Minimum PHP Version](https://camo.githubusercontent.com/4fa234720216417c22b6dba17fe57367ada3abcf95c6c6e949fcbb4c529db559/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d3838393242462e7376673f6c6f676f3d706870)](https://php.net/)

An OPCache preloader for CakePHP.

Reference:

This package is meant to provide an easy way for CakePHP application developers to generate preload files. Goals:

- Generate an OPCache preloader with a simple command.
- Allow optionally loading additional resources such as CakePHP plugins, userland app, and composer packages.
- Provide a simplistic API for writing a custom preloader.

For an alternative approach, checkout [DarkGhostHunter/Preloader](https://github.com/DarkGhostHunter/Preloader).

For an OPCache UI, checkout [amnuts/opcache-gui](https://github.com/amnuts/opcache-gui).

The current release is for CakePHP 5 and PHP 8.1, see previous releases for older versions of CakePHP and PHP.

VersionBranchCake VersionPHP Version1.\*[main](https://github.com/cnizzardini/cakephp-preloader)^5.0^8.10.\*[v0](https://github.com/cnizzardini/cakephp-preloader/tree/v0)^4.2^7.4Installation
------------

[](#installation)

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

The recommended way to install composer packages is:

```
composer require cnizzardini/cakephp-preloader
```

Next, load the plugin:

```
bin/cake plugin load CakePreloader --only-cli
```

Or via manual steps in the CakePHP [plugin documentation](https://book.cakephp.org/5/en/plugins.html#loading-a-plugin).

Usage
-----

[](#usage)

The easiest way to use CakePreloader is via the console command. This command can easily be included as part of your applications build process.

```
/srv/app $ bin/cake preloader --help
Generate a preload file

Usage:
cake preloader [options]

Options:

--app           Add your applications src directory into the preloader
--help, -h      Display this help.
--name          The preload file path. (default: ROOT . DS . 'preload.php')
--packages      A comma separated list of packages (e.g. vendor-name/package-name) to add to the preloader
--plugins       A comma separated list of your plugins to load or `*` to load all plugins/*
--cli           Should the preloader file exit when run via the php-cli? (default: true)
--quiet, -q     Enable quiet output.
--verbose, -v   Enable verbose output.
```

You may also load configurations from a `config/preloader_config.php` file. Please note, **command line arguments take precedence**. See [assets/preloader\_config.php](assets/preloader_config.php) for a sample configuration file. If you prefer handling configurations another way read the CakePHP documentation on [loading configuration files](https://book.cakephp.org/5/en/development/configuration.html#loading-configuration-files).

### Examples:

[](#examples)

Default loads in CakePHP core files excluding TestSuite, Console, Command, and Shell namespaces. The preload file is written to `ROOT . DS . 'preload.php'`:

```
bin/cake preloader
```

Include a list of composer packages:

```
bin/cake preloader --packages=cakephp/authentication,cakephp/chronos
```

Include your `APP` code:

```
bin/cake preloader --app
```

Include all your projects plugins:

```
bin/cake preloader --plugins=*
```

Include a list of your projects plugins:

```
bin/cake preloader --plugins=MyPlugin,MyOtherPlugin
```

### Before Write Event

[](#before-write-event)

You can extend functionality by listening for the `CakePreloader.beforeWrite` event. This is dispatched just before your preloader file is written.

```
(\Cake\Event\EventManager::instance())->on('CakePreloader.beforeWrite', function(Event $event){
    /** @var Preloader $preloader */
    $preloader = $event->getSubject();
    $resources = $preloader->getPreloadResources();
    // modify resources or whatever...
    $preloader->setPreloadResources($resources);
});
```

For more on events, read the CakePHP [Events System](https://book.cakephp.org/5/en/core-libraries/events.html#registering-listeners) documentation.

### Preloader Class

[](#preloader-class)

You can customize your OPCache Preloader using the same class used by the console command. Preloader uses a port of CakePHP 4.x's Filesystem class under the hood.

```
use CakePreloader\Preloader;

$preloader = new Preloader();
$preloader->loadPath('/required/path/to/files', function (\SplFileInfo $file) {
    // optional call back method, return true to add the file to the preloader
    return true;
});

// default path is ROOT . DS . 'preload.php'
$preloader->write('/optional/path/to/preloader-file.php');
```

Performance:
------------

[](#performance)

Obviously, these types of benchmarks should be taken with a bit of a gain of salt. I benchmarked this using apache bench with this project here:  which is a dockerized REST API (LEMP stack on alpine + php-fpm 8.0). CakePHP `DEBUG` was set to false.

```
extension=intl.so
extension=pdo_mysql.so
extension=sodium
extension=zip.so
zend_extension=opcache.so

[php]
session.auto_start = Off
short_open_tag = Off
opcache.preload_user=root
opcache.preload=/srv/app/preload.php
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
opcache.enable_cli = 0
opcache.enable = 1
opcache.revalidate_freq = 360
opcache.fast_shutdown = 1
realpath_cache_size = 4096K
realpath_cache_ttl = 600
```

Note: `opcache.preload_user=root` and `opcache.preload=/srv/app/preload.php` were disabled for the no preload run.

TypeJSON View (no db)JSON View (db select)OPCache Only892.69 \[#/sec\] (mean)805.29 \[#/sec\] (mean)OPCache Preload (default)1149.08 \[#/sec\] (mean)976.30 \[#/sec\] (mean)This is 28% more requests per second for JSON responses and 21% more requests per second with JSON + simple SQL select when OPCache Preload is enabled.

Tests / Analysis
----------------

[](#tests--analysis)

Test Suite:

```
composer test
```

Test Suite + Static Analysis:

```
composer check
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance82

Actively maintained with recent releases

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 95.9% 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 ~158 days

Recently: every ~212 days

Total

12

Last Release

92d ago

Major Versions

v0.1.5 → v1.0.02023-10-14

v0.1.7 → v1.0.12025-02-06

PHP version history (5 changes)v0.1.0PHP &gt;=7.2

v0.1.1PHP &gt;=7.4

v1.0.0PHP ^8.1

v0.1.6PHP ^7.4|^8.0

v0.x-devPHP &gt;=7.4.0,&lt;9

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/171294?v=4)[Chris Nizzardini](/maintainers/cnizzardini)[@cnizzardini](https://github.com/cnizzardini)

---

Top Contributors

[![cnizzardini](https://avatars.githubusercontent.com/u/171294?v=4)](https://github.com/cnizzardini "cnizzardini (47 commits)")[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (1 commits)")[![jamisonbryant](https://avatars.githubusercontent.com/u/6774110?v=4)](https://github.com/jamisonbryant "jamisonbryant (1 commits)")

---

Tags

clipreloadcakephppreloaderopcache preloadercakephp preloadercakephp opcache preloader

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cnizzardini-cakephp-preloader/health.svg)

```
[![Health](https://phpackages.com/badges/cnizzardini-cakephp-preloader/health.svg)](https://phpackages.com/packages/cnizzardini-cakephp-preloader)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1862.1M27](/packages/dereuromark-cakephp-ide-helper)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M367](/packages/wp-cli-php-cli-tools)

PHPackages © 2026

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