Problems with autoload namespace in composer

This is a more cosmetic question ...

I am using composer.phar in an existing project to autoload my classes.

This is an example composer.json snippet for my project named Acme :

 { "autoload": { "psr-0": { "Acme\\Mail": "modules/mail/src/", } } } 

and the parameter of my file structure is similar:

 app.php composer.phar vendor/ modules/ mail/ src/ Acme/ Mail.php (contains Acme\Mail\Mail.php) 

I have to stick to the "modules / mail" folder in my case and cannot rename them.

This basically works , but I need to create an additional Acme folder below src , which is a bit ugly.

How should startup be determined if I want to leave the highest part of the Acme namespace in my mail folder so that it looks like this:

 app.php composer.phar vendor/ modules/ mail/ src/ Mail.php (contains Acme\Mail\Mail.php) 

and i can still use it in php file:

 use Acme\Mail; $mail = new Mail(); 

Or is it not possible?

+4
source share
2 answers

You can use classmap generation if you don't want to follow the PSR-0 standard (which you really need to revise). See Link http://getcomposer.org/doc/04-schema.md#autoload

+1
source

Source: https://habr.com/ru/post/1434194/


All Articles