A native implementation of PSR-0 using only the autoloader from the PSR-0 example in the spec would expect a folder structure like this:
League\Oauth2\Client\Foo = myapp/somefolder/League/Oauth2/Client/Foo.php
League\Oauth2\Server\Bar = myapp/somefolder/League/Oauth2/Server/Bar.php
If I was making these as packages, I could make them into two packages, which would be installed in different locations, because thats how Composer rolls:
League\Oauth2\Client\Foo = myapp/vendor/league/oauth2/src/League/Oauth2/Client/Foo.php
League\Oauth2\Server\Bar = myapp/vendor/league/oauth2-server/src/League/Oauth2/Server/Bar.php
Composer allows multiple paths within a namespace. We are using this for Stack to ensure that we can use classes named like
Stack\Builder
,Stack\Session
, andStack\OAuth
for individual middlewares. This is accomplished by settingStack
as the PSR-0 root for each Composer package. Works like a charm.To see this in action, here is the
vendor/composer/autoload_classmap.php
generated when youcomposer install
Stack\OAuth: