PHPackages                             varunsridharan/php-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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. varunsridharan/php-autoloader

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

varunsridharan/php-autoloader
=============================

Lightweight PSR-4 PHP Autoloader Class.

2.6(6y ago)232.6k2[1 PRs](https://github.com/varunsridharan/php-autoloader/pulls)1GPL-3.0-or-laterPHP

Since Dec 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/varunsridharan/php-autoloader)[ Packagist](https://packagist.org/packages/varunsridharan/php-autoloader)[ RSS](/packages/varunsridharan-php-autoloader/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)DependenciesVersions (17)Used By (1)

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

[](#php-autoloader)

Lightweight PSR-4 PHP Autoloader Class.

[![Latest Stable Version](https://camo.githubusercontent.com/d84b881492e8ce544d55a47e655d0f83dd2b7cb3fad342a1ecb6607184e4b5fe/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f7068702d6175746f6c6f616465722f76657273696f6e)](https://packagist.org/packages/varunsridharan/php-autoloader)[![Total Downloads](https://camo.githubusercontent.com/e99d2ad47e8f908afabb3b741e9ba258527a03a660c0816b9e149bac9b39a22e/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f7068702d6175746f6c6f616465722f646f776e6c6f616473)](https://packagist.org/packages/varunsridharan/php-autoloader)[![Latest Unstable Version](https://camo.githubusercontent.com/fc7651d593dc253b94154e2d700029f34d6dd0140f8b5280f04dc7daea476958/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f7068702d6175746f6c6f616465722f762f756e737461626c65)](//packagist.org/packages/varunsridharan/php-autoloader)[![License](https://camo.githubusercontent.com/84ec5297b075f5dc419c002a9023fbe8582c9748691e5937cd53e57556afde95/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f7068702d6175746f6c6f616465722f6c6963656e7365)](https://packagist.org/packages/varunsridharan/php-autoloader)[![composer.lock available](https://camo.githubusercontent.com/c98f465b92c12c0c9b5f4f0670afffab3fd8343685586da84e891c0cd731ed4f/68747470733a2f2f706f7365722e707567782e6f72672f766172756e73726964686172616e2f7068702d6175746f6c6f616465722f636f6d706f7365726c6f636b)](https://packagist.org/packages/varunsridharan/php-autoloader)

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

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **PHP\_Autoloader library**, simply:

```
$ composer require varunsridharan/php-autoloader

```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
$ composer require varunsridharan/php-autoloader --prefer-source

```

You can also **clone the complete repository** with Git:

```
$ git clone https://github.com/varunsridharan/php-autoloader.git

```

Or **install it manually**:

[Download autoloader.php](https://raw.githubusercontent.com/varunsridharan/php-autoloader/master/src/autoloader.php):

```
$ wget https://raw.githubusercontent.com/varunsridharan/php-autoloader/master/src/autoloader.php

```

Usage
-----

[](#usage)

### Arguments

[](#arguments)

- **`$namespace` :** PHP Namspace To Handle Autoload For
- **`$classmap` :**  Generated Classmap File.
- **`$path` :** Full Path to lookup for php files
- **`$options` :** An Array of useful Arguments.
- **`$prepend` :** Option to prepend / append current autoloader with exists autoloaders.

#### `$options` Arguments

[](#options-arguments)

```
  array(
      /**
       * An Array of Class Namespace to Exclude While Checking for current namespace.
       * Eg
       * Main Namespace \Testing\Core
       * Exclude \Testing\Core\Abstracts
       */
      'exclude' => false,

      /**
       * Custom Option To Quickly Remap A Class File.
       * If any class added then it will not search.
       * instead it gets the location from here and loads it.
       * An Array of class and its file location
       */
      'mapping' => array(),

      /**
       * Set To True / False.
       */
      'debug'   => false,
  );
```

### Example Folder Stucture

[](#example-folder-stucture)

```
  | - src\
  | -- class1\
  | --- class1.php
  | -- class2\
  | --- class2.php
  | --- class3\
  | ---- class3.php
  | - loader.php
  | - index.php
```

### `loader.php` SourceCode

[](#loaderphp-sourcecode)

```
  $autoloader = new \Varunsridharan\PHP\Autoloader('varun',__DIR__.'/src/',array(
      'mapping' => array(
          'varun\class2\class3\class3' => 'src/class2/class3/class3.php',
      )
  ))
```

### `index.php` SoruceCode

[](#indexphp-sorucecode)

```
  require __DIR__.'loader.php';

  $class1 = new \varun\class1\class1(); // This file is autoloaded based on the namespace
  $class2 = new \varun\class1\class2(); // This file is autoloaded based on the namespace
  $class3 = new \varun\class1\class3(); // This file is loaded using the data from remap array
```

---

📝 Changelog
-----------

[](#-changelog)

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

[Checkout CHANGELOG.md](https://github.com/varunsridharan/php-autoloader/blob/main/CHANGELOG.md)

🤝 Contributing
--------------

[](#-contributing)

If you would like to help, please take a look at the list of [issues](https://github.com/varunsridharan/php-autoloader/issues/).

📜 License &amp; Conduct
-----------------------

[](#--license--conduct)

- [**GNU General Public License v3.0**](https://github.com/varunsridharan/php-autoloader/blob/main/LICENSE) © [Varun Sridharan](website)
- [Code of Conduct](https://github.com/varunsridharan/.github/blob/main/CODE_OF_CONDUCT.md)

📣 Feedback
----------

[](#-feedback)

- ⭐ This repository if this project helped you! 😉
- Create An [🔧 Issue](https://github.com/varunsridharan/php-autoloader/issues/) if you need help / found a bug

💰 Sponsor
---------

[](#-sponsor)

[I](https://sva.onl/twitter/) fell in love with open-source in 2013 and there has been no looking back since! You can read more about me [here](https://sva.onl/website/). If you, or your company, use any of my projects or like what I’m doing, kindly consider backing me. I'm in this for the long run.

- ☕ How about we get to know each other over coffee? Buy me a cup for just [**$9.99**](https://sva.onl/buymeacoffee)
- ☕️☕️ How about buying me just 2 cups of coffee each month? You can do that for as little as [**$9.99**](https://sva.onl/buymeacoffee)
- 🔰 We love bettering open-source projects. Support 1-hour of open-source maintenance for [**$24.99 one-time?**](https://sva.onl/paypal)
- 🚀 Love open-source tools? Me too! How about supporting one hour of open-source development for just [**$49.99 one-time ?**](https://sva.onl/paypal)

Connect &amp; Say 👋
-------------------

[](#connect--say-)

- **Follow** me on [👨‍💻 Github](https://sva.onl/github/) and stay updated on free and open-source software
- **Follow** me on [🐦 Twitter](https://sva.onl/twitter/) to get updates on my latest open source projects
- **Message** me on [📠 Telegram](https://sva.onl/telegram/)
- **Follow** my pet on [Instagram](https://www.instagram.com/sofythelabrador/) for some *dog-tastic* updates!

---

*Built With ♥ By [Varun Sridharan](https://sva.onl/twitter) [ ![](https://camo.githubusercontent.com/ac180da7a81f72a639abce09c4827e7bacfdd3b82586b657387a7f84430c7b7f/68747470733a2f2f63646e2e73766172756e2e6465762f666c61672d696e6469612e6a7067)](https://en.wikipedia.org/wiki/India)*

 [![](https://camo.githubusercontent.com/51991d58f40dac784a0c08b9c5c16c66c59ef5bdf083e3d49e4f617ef98e03ee/68747470733a2f2f63646e2e73766172756e2e6465762f636f64656973706f657472792e706e67)](https://camo.githubusercontent.com/51991d58f40dac784a0c08b9c5c16c66c59ef5bdf083e3d49e4f617ef98e03ee/68747470733a2f2f63646e2e73766172756e2e6465762f636f64656973706f657472792e706e67)

---

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

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

Recently: every ~37 days

Total

15

Last Release

2415d ago

Major Versions

1.4 → 2.02019-05-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/522dc9d037e4b0517ee9b76cd63d75a6331b0e578afa9b27fee84b02863ace80?d=identicon)[varunsridharan](/maintainers/varunsridharan)

---

Top Contributors

[![varunsridharan](https://avatars.githubusercontent.com/u/1884287?v=4)](https://github.com/varunsridharan "varunsridharan (38 commits)")

---

Tags

autoload-classautoloaderautoloadingautoloading-functionsautoloadphpcomposercomposer-autoloaderphpphp-autoloadphp-autoloaderphp-libraryphp-librayphp5php56php7php71php72psr-4vsp-libs

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/type-resolver

A PSR-5 based resolver of Class names, Types and Structural Element Names

9.2k719.5M166](/packages/phpdocumentor-type-resolver)[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[stella-maris/clock

A pre-release of the proposed PSR-20 Clock-Interface

7947.5M2](/packages/stella-maris-clock)[wptrt/wpthemereview

PHP\_CodeSniffer rules (sniffs) to verify theme compliance with the rules for theme hosting on wordpress.org

217736.5k29](/packages/wptrt-wpthemereview)[inpsyde/modularity

Modular PSR-11 implementation for WordPress plugins, themes or libraries.

54383.3k3](/packages/inpsyde-modularity)

PHPackages © 2026

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