PHPackages                             actra/autoloader - 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. actra/autoloader

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

actra/autoloader
================

A simple, lightweight, and efficient PHP Autoloader supporting PSR-4, PSR-0, and filesystem caching with OPcache support.

v1.1.0(1mo ago)0121MITPHPPHP &gt;=8.2

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/Actra-AG/autoloader)[ Packagist](https://packagist.org/packages/actra/autoloader)[ RSS](/packages/actra-autoloader/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

PHP Autoloader
==============

[](#php-autoloader)

A simple, lightweight, and efficient PHP Autoloader that supports PSR-4, PSR-0, filesystem caching, and custom file suffix lists. This autoloader is designed to be easy to integrate into any PHP project without the overhead of complex dependency management if you need a standalone solution.

Features
--------

[](#features)

- **PSR-4 and PSR-0 Support**: Load classes according to modern and legacy standards.
- **Filesystem Caching**: Boost performance by caching class-to-file mappings in a PHP file.
- **Custom Suffixes**: Supports multiple file extensions (e.g., `.php`, `.inc.php`, `.class.php`).
- **Namespace Prefixes**: Easily map namespaces or prefixes to specific directories.
- **Lightweight**: Zero external dependencies.

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

[](#installation)

### Via Composer (Recommended)

[](#via-composer-recommended)

To install the autoloader via Composer, run:

```
composer require actra/autoloader
```

### Standalone (Manual)

[](#standalone-manual)

If you're not using Composer, simply include the source files in your project:

```
require_once 'src/Autoloader.php';
```

Basic Usage
-----------

[](#basic-usage)

### PSR-4 Autoloading

[](#psr-4-autoloading)

```
use actra\autoloader\Autoloader;
use actra\autoloader\AutoloaderPath;

// Register the autoloader
$autoloader = Autoloader::register();

// Add a path for a namespace
$autoloader->addPath(autoloaderPath: new AutoloaderPath(
    path: __DIR__ . '/src',
    prefix: 'MyProject\\'
));
```

### PSR-0 Autoloading (Legacy)

[](#psr-0-autoloading-legacy)

```
use actra\autoloader\Autoloader;
use actra\autoloader\AutoloaderPath;
use actra\autoloader\AutoloaderPathMode;

$autoloader = Autoloader::register();

$autoloader->addPath(autoloaderPath: new AutoloaderPath(
    path: __DIR__ . '/lib',
    prefix: 'Legacy_',
    autoloaderPathMode: AutoloaderPathMode::PSR0
));
```

Advanced Features
-----------------

[](#advanced-features)

### Filesystem Caching

[](#filesystem-caching)

By default, the autoloader uses a local cache file at `src/cache/autoloader.php`. This significantly speeds up class loading in production environments by leveraging OPcache. The cache directory is automatically created if it doesn't exist.

To use a custom cache location, provide a path when registering:

```
$autoloader = Autoloader::register(cacheFilePath: __DIR__.' /cache/autoloader.php');
```

The cache is automatically updated and saved when the script finishes execution (using a destructor).

### Custom File Suffixes

[](#custom-file-suffixes)

If your project uses non-standard file extensions, you can specify them in the `AutoloaderPath` constructor:

```
$autoloader->addPath(autoloaderPath: new AutoloaderPath(
    path: __DIR__ . '/src',
    prefix: 'App\\',
    fileSuffixList: ['.php', '.class.php', '.inc']
));
```

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

[](#requirements)

- PHP 8.2 or higher (Uses `readonly` classes and enums)

License
-------

[](#license)

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

---

© Actra AG -

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance89

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

2

Last Release

55d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db110c9aa8b7f41b77d42bb1d3da4d493aa513e9a4f5a49e20169e46ee9c653f?d=identicon)[JayQ1982](/maintainers/JayQ1982)

---

Top Contributors

[![JayQ1982](https://avatars.githubusercontent.com/u/6882691?v=4)](https://github.com/JayQ1982 "JayQ1982 (6 commits)")

### Embed Badge

![Health badge](/badges/actra-autoloader/health.svg)

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

PHPackages © 2026

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