PHPackages                             mouf/classname-mapper - 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. mouf/classname-mapper

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

mouf/classname-mapper
=====================

Provides a way to find in which PHP files a class will be looked upon.

v1.0.2(7y ago)112.4M↓46%3[2 PRs](https://github.com/thecodingmachine/classname-mapper/pulls)5MITPHPPHP &gt;=5.4.0

Since Feb 1Pushed 6y ago5 watchersCompare

[ Source](https://github.com/thecodingmachine/classname-mapper)[ Packagist](https://packagist.org/packages/mouf/classname-mapper)[ Docs](http://mouf-php.com/packages/thecodingmachine/classname-mapper)[ RSS](/packages/mouf-classname-mapper/feed)WikiDiscussions 1.1 Synced 1w ago

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

[![Latest Stable Version](https://camo.githubusercontent.com/67426917f25c43621b44e0d92f313ef8fa036cfd6a7c86dedb54997dc0ff6e35/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f636c6173736e616d652d6d61707065722f762f737461626c65)](https://packagist.org/packages/mouf/classname-mapper)[![Total Downloads](https://camo.githubusercontent.com/c7b12ab616eb218b4c052ab99609b04142641dc6af4c02e0cdae13715299f772/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f636c6173736e616d652d6d61707065722f646f776e6c6f616473)](https://packagist.org/packages/mouf/classname-mapper)[![Latest Unstable Version](https://camo.githubusercontent.com/59026fbee4fb04dceeecd1ad4d2a3a5164e56df5ca116f5151301ac6ec7201e4/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f636c6173736e616d652d6d61707065722f762f756e737461626c65)](https://packagist.org/packages/mouf/classname-mapper)[![License](https://camo.githubusercontent.com/a2cbdbe36a854feadeea0ec75bb59ffda49bec91e672155a54f419a7bce78742/68747470733a2f2f706f7365722e707567782e6f72672f6d6f75662f636c6173736e616d652d6d61707065722f6c6963656e7365)](https://packagist.org/packages/mouf/classname-mapper)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/89236eb1420ae207e4b04620f07d37238e656237960c8b47e8a53d0794bb989d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746865636f64696e676d616368696e652f636c6173736e616d652d6d61707065722f6261646765732f7175616c6974792d73636f72652e706e673f623d312e30)](https://scrutinizer-ci.com/g/thecodingmachine/classname-mapper/?branch=1.0)[![Build Status](https://camo.githubusercontent.com/d69bb915c8203e32f0d3dee9d09f6b4a11f8ce6e13629189ceffa98deab6a21f/68747470733a2f2f7472617669732d63692e6f72672f746865636f64696e676d616368696e652f636c6173736e616d652d6d61707065722e7376673f6272616e63683d312e30)](https://travis-ci.org/thecodingmachine/classname-mapper)[![Coverage Status](https://camo.githubusercontent.com/2003bd7a2dac02dfb296864920bb4161dde7df4e6be618293d11069780d4fcee/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f746865636f64696e676d616368696e652f636c6173736e616d652d6d61707065722f62616467652e7376673f6272616e63683d312e3026736572766963653d676974687562)](https://coveralls.io/github/thecodingmachine/classname-mapper?branch=1.0)

ClassName mapper
================

[](#classname-mapper)

What is it?
-----------

[](#what-is-it)

Some packages generate PHP classes. When a package generates a class, it needs to know in which directory to put the PHP file, so that the class can be autoloaded by the autoloader. This package is here to help you find in which directory to write your PHP file.

This package contains a simple `ClassNameMapper` PHP class.

This class will map a fully qualified class name (FQCN) to one or many possible file names according to PSR-0 or PSR-4 rules defined in your `composer.json` file.

So you pass the `ClassNameMapper` a FQCN, and it gives you back a list of file paths that will be checked by the Composer autoloader.

This is very useful in case you want to generate PHP classes, and you don't know where to write those classes.

Sample
------

[](#sample)

Imagine your `composer.json` looks like this:

```
{
    "require" : {
        "mouf/classname-mapper": "~1.0"
    },
    "autoload" : {
        "psr-4" : {
            "Acme\\" : "src/"
        }
    }
}
```

Now, let's say you want to create a `Acme\Controller\MyController` class. Where should you put the class? To a PHP developer, it is obvious the class will go in `src/Controller/MyController.php`. To a PHP program, it is a tricky problem. The `ClassNameMapper` is here to solve the problem:

```
use Mouf\Composer\ClassNameMapper;

// This will create a mapper from your root composer file.
$mapper = ClassNameMapper::createFromComposerFile();

$files = $mapper->getPossibleFileNames('Acme\Controller\MyController');
// $files == ["src/Controller/MyController.php"];
```

You can also query the `ClassNameMapper` for a list of all namespaces that are configured in your `composer.json` file:

```
$namespaces = $mapper->getManagedNamespaces();
// $namespaces == ["Acme\\"];
```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~270 days

Total

5

Last Release

2700d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (15 commits)")[![BackEndTea](https://avatars.githubusercontent.com/u/14289961?v=4)](https://github.com/BackEndTea "BackEndTea (1 commits)")

---

Tags

composerautoload

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mouf-classname-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/mouf-classname-mapper/health.svg)](https://phpackages.com/packages/mouf-classname-mapper)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k193.1M3.0k](/packages/composer-composer)[jean85/pretty-package-versions

A library to get pretty versions strings of installed dependencies

1.3k306.6M74](/packages/jean85-pretty-package-versions)[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k40.0M2.6k](/packages/ergebnis-composer-normalize)[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89354.3M344](/packages/nette-robot-loader)[bamarni/composer-bin-plugin

No conflicts for your bin dependencies

52823.6M1.0k](/packages/bamarni-composer-bin-plugin)[composer/metadata-minifier

Small utility library that handles metadata minification and expansion.

181120.4M21](/packages/composer-metadata-minifier)

PHPackages © 2026

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