Download the PHP package mouf/classname-mapper without Composer
On this page you can find all versions of the php package mouf/classname-mapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mouf/classname-mapper
More information about mouf/classname-mapper
Files in mouf/classname-mapper
Package classname-mapper
Short Description Provides a way to find in which PHP files a class will be looked upon.
License MIT
Homepage http://mouf-php.com/packages/thecodingmachine/classname-mapper
Informations about the package classname-mapper
ClassName mapper
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
Imagine your composer.json
looks like this:
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:
You can also query the ClassNameMapper
for a list of all namespaces that are configured in your composer.json
file: