Paul Stanley
Paul Stanley

Reputation: 4098

Add global namespace to psr4 autoloader

I am currently doing something like this:

$loader->addPsr4('Application\\Config\\', __DIR__ . '/../config/test');

This means I can do any file in the directory test with namespace Application\Config\.

Is it possible to a similar setup/trick to do this for the global namespace?

Upvotes: 0

Views: 498

Answers (1)

kuba
kuba

Reputation: 3870

You can do:

$loader->addClassMap(['src\\']);

and this will get you all the files in directory src (no matter what namespace there will be).

Upvotes: 2

Related Questions