PHPackages                             intahwebz/lowmemoryclassloader - 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. intahwebz/lowmemoryclassloader

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

intahwebz/lowmemoryclassloader
==============================

A PHP class loader that uses a minimal amount of memory.

1.0.1(12y ago)1136MITPHP

Since Sep 10Pushed 12y ago4 watchersCompare

[ Source](https://github.com/Danack/LowMemoryClassloader)[ Packagist](https://packagist.org/packages/intahwebz/lowmemoryclassloader)[ RSS](/packages/intahwebz-lowmemoryclassloader/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (4)Used By (0)

LowMemoryClassloader
====================

[](#lowmemoryclassloader)

A PHP Composer compatible classloader that uses less memory.

Why
===

[](#why)

I'm an ex-video games developer. I can't stand seeing huge chunks of memory being used when it isn't necessary.

After running `composer--optimize-autoloader update` on my current project, the 'optimised' version of the class loader looks like this:  which quite frankly appalls. It takes up 645kB of memory, which is about 30% of the memory needed to display a page in the framework I use.

Although some sort of optimization for figuring out where the files for classes exist is needed (as file\_exists() calls are too darn slow, and must be avoided at all costs) we really ought to do better than using up that much memory.

Also, Composer does not cache where the files for classes are that it doesn't install. E.g. all generated classes that you use in a project have a `file_exists()` call made for each request. The LowMemoryClassloader caches this away.

How it works
============

[](#how-it-works)

OPCache stores optimized versions of PHP files. We can use that as a cache of which files have already been loaded in a previous PHP script, which effectively gives us a cache of what files contain which classes from a small list of available possibilities.

So instead of storing a massive list of where all the individual file for classes are, we can just use the much shorter list of top-level namespaces (from the file autoload\_namespaces.php) to search for files once, and then, effectively, cache the result through OPCache.

The only time when the full classmap file is loaded is when PHP tries to autoload a class that isn't cached by OPCache, and isn't namespaced.

The LowMemoryClassloader requires you to use my fork of OPCache from  as it adds the function `opcache_script_cached($scriptName)` to allow you to check if a script is cached in OPCache.

How you use it
==============

[](#how-you-use-it)

- Compile in the modified version of OPCache.
- In your PHP script wherever you include the Composer classloader `require_once('../vendor/autoload.php');` replace it with the LowMemoryClassLoader `require_once('../vendor/intahwebz/lowmemoryclassloader/LowMemoryClassloader.php');`
- That's it.

Behaviour difference to Composer
================================

[](#behaviour-difference-to-composer)

The only known difference in behaviour to the Composer autoloader is that when the LowMemoryClassloader fails to load the file for a class, it does not cache that fact, and will try to find the class again, on the next attempt to load it. This is the correct behaviour IMHO, as it makes runtime code generation be easier to handle.

TODO
====

[](#todo)

Benchmark this compared to the classloader that ships with Composer. It should be significantly faster on machines that are under at least a medium amount of load. It will definitely be faster for applications that use dynamically generated classes which have a high overhead with Composer's classloader.

However I'm running PHP5.5 in a VM on my laptop, and it's performance is wildly divergent from a real server, so I'm not going to say any benchmarks which I know are unreliable.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~79 days

Total

3

Last Release

4519d ago

Major Versions

0.1.0 → 1.0.02013-09-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/9db967c6005625e444a502fb830a30669b9fed53bfbc67e81a054508c0975a6b?d=identicon)[Danack](/maintainers/Danack)

---

Top Contributors

[![Danack](https://avatars.githubusercontent.com/u/1505719?v=4)](https://github.com/Danack "Danack (8 commits)")

---

Tags

autoloaderoptimizedclassloader

### Embed Badge

![Health badge](/badges/intahwebz-lowmemoryclassloader/health.svg)

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

###  Alternatives

[typo3/class-alias-loader

Amends the composer class loader to support class aliases to provide backwards compatibility for packages

4414.6M28](/packages/typo3-class-alias-loader)[automattic/jetpack-autoloader

Creates a custom autoloader for a plugin or theme.

576.1M119](/packages/automattic-jetpack-autoloader)[roots/bedrock-autoloader

An autoloader that enables standard plugins to be required just like must-use plugins

426.1M62](/packages/roots-bedrock-autoloader)[lochmueller/autoloader

Automatic components loading of ExtBase extensions to get more time for coffee in the company ;) This ext is not a PHP SPL autoloader or class loader - it is better! Loads CommandController, Xclass, Hooks, FlexForms, Slots, TypoScript, TypeConverter, BackendLayouts and take care of createing needed templates, TCA configuration or translations at the right location.

20370.7k5](/packages/lochmueller-autoloader)[linkorb/autotune

Tune your autoloader

177.3k17](/packages/linkorb-autotune)[bnomei/autoloader-for-kirby

Helper to automatically load various Kirby extensions in a plugin

185.7k2](/packages/bnomei-autoloader-for-kirby)

PHPackages © 2026

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