PHPackages                             huynh/autoload-test - 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. huynh/autoload-test

ActiveLibrary

huynh/autoload-test
===================

Autoload testing between psr-0 and psr-4

15PHP

Since May 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/franknyn/autoload-test)[ Packagist](https://packagist.org/packages/huynh/autoload-test)[ RSS](/packages/huynh-autoload-test/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Composer Autoloading
--------------------

[](#composer-autoloading)

- Composer autoloading provides a variety of different [autoloading functionality](https://getcomposer.org/doc/04-schema.md#autoload), although it is recommended to use PSR 4 autoloading which is the default implementation.
- Autoloading classes with namespaces means it has to follow a convention, usually that convention involves using folders

Namespace/ folder convention.
-----------------------------

[](#namespace-folder-convention)

- Classes should be stored in folders according to their namespaces.
- In general, you will create a src/ directory in your root folder, sitting at the same level as vendor/, and add your projects there. Below is an example of folder structure.

```
.
+-- src
    |
    +-- Book
    |   +-- History
    |   |   +-- UnitedStates.php - namespace Book\History;
    +-- Vehicle
    |   +-- Air
    |   |   +-- Wings
    |   |   |   +-- Airplane.php - namespace Vehicle\Air\Wings;
    |   +-- Road
    |   |   +-- Car.php - namespace Vehicle\Road;
+-- tests
    +-- test.php
+-- vendor

```

Difference between psr-0 and psr-4 autoloading
----------------------------------------------

[](#difference-between-psr-0-and-psr-4-autoloading)

- See
- See

### psr-0

[](#psr-0)

It is deprecated. Looking at [`vendor/composer/autoload_namespaces.php`](https://jtreminio.com/2012/10/composer-namespaces-in-5-minutes/#the-autoload_namespaces.php-file) file you can see the namespaces and the directories that they are mapped to.

**composer.json**

```
    "autoload": {
        "psr-0": {
            "Book\\": "src/",
            "Vehicle\\": "src/"
        }
    }

```

- Looking for **Book**\\History\\UnitedStates in **src/Book**/History/UnitedStates.php
- Looking for **Vehicle**\\Air\\Wings\\Airplane in **src/Vehicle**/Air/Wings/Airplane.php

### psr-4

[](#psr-4)

Looking at `vendor/composer/autoload_psr4.php` file you can see the namespaces and the directories that they are mapped to.

**composer.json**

```
    "autoload": {
        "psr-4": {
            "Book\\": "src/",
            "Vehicle\\": "src/"
        }
    }

```

- Looking for **Book**\\History\\UnitedStates in **src**/History/UnitedStates.php
- Looking for **Vehicle**\\Air\\Wings\\Airplane in **src**/Air/Wings/Airplane.php

**composer.json**

```
    "autoload": {
        "psr-4": {
            "Book\\": "src/Book/",
            "Vehicle\\": "src/Vehicle/"
        }
    }

```

- Looking for **Book**\\History\\UnitedStates **src/Book**/History/UnitedStates.php
- Looking for **Vehicle**\\Air\\Wings\\Airplane in **src/Vehicle**/Air/Wings/Airplane.php

Be ready for production
-----------------------

[](#be-ready-for-production)

Just a reminder, before deploying your code in production, don't forget to optimize the autoloader:

```
$ composer dump-autoload --optimize

```

This can also be used while installing packages with the --optimize-autoloader option. Without that optimization, you may notice a performance loss from 20 to 25%.

Usage
-----

[](#usage)

See `tests/test.php`

```
composer install
php tests/test.php

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4122b669061decaff3d91678f13b3e898e3e07e9d91113d9e32e9a0d37da8116?d=identicon)[franknyn](/maintainers/franknyn)

---

Top Contributors

[![franknyn](https://avatars.githubusercontent.com/u/10736259?v=4)](https://github.com/franknyn "franknyn (2 commits)")

### Embed Badge

![Health badge](/badges/huynh-autoload-test/health.svg)

```
[![Health](https://phpackages.com/badges/huynh-autoload-test/health.svg)](https://phpackages.com/packages/huynh-autoload-test)
```

PHPackages © 2026

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