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

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

horde/autoloader
================

Autoloader library

v3.0.0(2w ago)14.0k↑34.2%413LGPL-2.1-onlyPHPPHP ^8CI failing

Since Apr 28Pushed 2w ago6 watchersCompare

[ Source](https://github.com/horde/Autoloader)[ Packagist](https://packagist.org/packages/horde/autoloader)[ Docs](https://www.horde.org/libraries/Horde_Autoloader)[ RSS](/packages/horde-autoloader/feed)WikiDiscussions FRAMEWORK\_6\_0 Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (13)Used By (13)

Horde Autoloader
================

[](#horde-autoloader)

PSR-0 and PSR-4 compliant autoloader for PHP 8.0+

Why Horde Autoloader?
---------------------

[](#why-horde-autoloader)

Horde Autoloader predates PSR-0 and is mostly maintained for legacy and educational purposes. Horde itself primarily uses composer autoloader as does everybody else. Remaining calls into Horde Autoloader from the Horde Framework are going to be removed step by step.

If you need a config-is-code, self-contained, PSR-0 capable autoloader and composer autoloader is not an option, give it a try. Your reasons are yours.

Features
--------

[](#features)

- **PSR-4 Support** - Autoloading with namespaces
- **PSR-0 Support** - PEAR-style autoloading without namespaces, underscores as subdir separators.
- **Classpath Mappers** - Application, Prefix, PrefixString patterns
- **PHP 8.0+** - Full type safety and modern features
- **LIFO Ordering** - Last-added mapper searched first
- **Callback Support** - Execute code after class loads
- **No Dependencies** - Self-contained library

Quick Start
-----------

[](#quick-start)

### Modern (PSR-4 with PSR-0 support)

[](#modern-psr-4-with-psr-0-support)

```
// Autoloader bootstraps itself - require files explicitly
require_once __DIR__ . '/vendor/horde/autoloader/src/Autoloader.php';
require_once __DIR__ . '/vendor/horde/autoloader/src/ClassPathMapper/Psr4.php';

use Horde\Autoloader\Autoloader;
use Horde\Autoloader\ClassPathMapper\Psr4;

$autoloader = new Autoloader();
$psr4 = new Psr4(enablePsr0Fallback: false);
$psr4->addNamespace('Acme\Log', __DIR__ . '/vendor/acme/log/src');
$autoloader->addClassPathMapper($psr4);
$autoloader->registerAutoloader();
```

### Legacy (PSR-0 based PSR-0)

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

```
// Autoloader bootstraps itself - require files explicitly
require_once __DIR__ . '/vendor/horde/autoloader/lib/Horde/Autoloader.php';

$autoloader = new Horde_Autoloader();
$autoloader->addClassPathMapper(
    new Horde_Autoloader_ClassPathMapper_Default(__DIR__ . '/lib')
);
$autoloader->registerAutoloader();
```

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

[](#installation)

```
composer require horde/autoloader
```

Documentation
-------------

[](#documentation)

- **[Examples (Legacy PSR-0)](doc/examples-lib-psr0.php)** - PSR-0 usage examples
- **[Examples (Modern)](doc/examples-src-modern.php)** - PSR-4 and modern features
- **[Upgrading Guide](doc/UPGRADING.md)** - Migration from PSR-0 to PSR-4
- **[Changelog](doc/changelog.yml)** - Version history

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

[](#requirements)

- PHP 8.0 or higher

Key Differences: PSR-0 vs PSR-4
-------------------------------

[](#key-differences-psr-0-vs-psr-4)

FeaturePSR-0PSR-4UnderscoresConverted to `/`Preserved as-isNamespace mappingSimple pathPrefix → base directoryTop-level classesAllowedRejected (requires namespace)Multiple base dirsNoYes### PSR-0 Example

[](#psr-0-example)

```
// Class: Vendor_Package_Class_Name
// Maps to: vendor/Vendor/Package/Class/Name.php
```

### PSR-4 Example

[](#psr-4-example)

```
// Prefix: Vendor\Package → /vendor/package/src
// Class: \Vendor\Package\Class_Name
// Maps to: /vendor/package/src/Class_Name.php (underscore preserved!)
```

Available Mappers
-----------------

[](#available-mappers)

### Modern (src/)

[](#modern-src)

- **`Psr4`** - PSR-4 compliant autoloader with namespace prefix mapping
- **`DefaultMapper`** - PSR-0 compliant mapper (underscores → directories)
- **`Application`** - Application-specific MVC pattern mapper
- **`Prefix`** - Regex-based prefix matching
- **`PrefixString`** - Fast case-insensitive string prefix matching

### Legacy (lib/)

[](#legacy-lib)

- **`Horde_Autoloader_ClassPathMapper_Default`** - PSR-0 mapper
- **`Horde_Autoloader_ClassPathMapper_Application`** - Application mapper
- **`Horde_Autoloader_ClassPathMapper_Prefix`** - Regex prefix
- **`Horde_Autoloader_ClassPathMapper_PrefixString`** - String prefix

Testing
-------

[](#testing)

```
# Run all tests
phpunit

# Run specific test suites
phpunit --testsuite unit        # Legacy PSR-0 tests
phpunit --testsuite modern      # Modern PSR-4 tests
phpunit --testsuite integration # Real file loading tests
```

License
-------

[](#license)

LGPL-2.1-only

Links
-----

[](#links)

- **Homepage**: [https://www.horde.org/libraries/Horde\_Autoloader](https://www.horde.org/libraries/Horde_Autoloader)
- **Repository**:
- **PSR-4 Specification**:
- **PSR-0 Specification**:

Credits
-------

[](#credits)

- **Authors**: Bob Mckee, Chuck Hagenbuch
- **Maintainers**: Jan Schneider, Ralf Lang

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community36

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 64.5% 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 ~508 days

Recently: every ~480 days

Total

9

Last Release

18d ago

Major Versions

2.1.2 → 3.0.0alpha12021-02-23

PHP version history (6 changes)2.1.1PHP &gt;=5.3.0,&lt;=6.0.0alpha1

2.1.2PHP &gt;=5.3.0,&lt;=8.0.0alpha1

3.0.0alpha1PHP ^7

v3.0.0alpha4PHP ^7.4 || ^8

v3.0.0alpha5PHP ^8.2

v3.0.0beta1PHP ^8

### Community

Maintainers

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

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

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

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

![](https://www.gravatar.com/avatar/816e2b926f25f8cd2939054c7a7173011b4303d690e25ab61bf33cf8c7cf71ae?d=identicon)[tdannhauer](/maintainers/tdannhauer)

---

Top Contributors

[![yunosh](https://avatars.githubusercontent.com/u/379318?v=4)](https://github.com/yunosh "yunosh (91 commits)")[![ralflang](https://avatars.githubusercontent.com/u/646976?v=4)](https://github.com/ralflang "ralflang (29 commits)")[![slusarz](https://avatars.githubusercontent.com/u/381003?v=4)](https://github.com/slusarz "slusarz (12 commits)")[![mrubinsk](https://avatars.githubusercontent.com/u/66822?v=4)](https://github.com/mrubinsk "mrubinsk (5 commits)")[![Schlue](https://avatars.githubusercontent.com/u/10165635?v=4)](https://github.com/Schlue "Schlue (2 commits)")[![wrobel](https://avatars.githubusercontent.com/u/10232?v=4)](https://github.com/wrobel "wrobel (1 commits)")[![powercycle](https://avatars.githubusercontent.com/u/2614846?v=4)](https://github.com/powercycle "powercycle (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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