I use the following directory structure based on my understanding of how namespaces in PHP work:
project_root
app/
| lib/
| | MyCompany/
Taken from the documentation you linked:
{
"autoload": {
"psr-4": {
"MyCompany\\": "app/lib/MyCompany/",
}
}
}
This is pretty self explanatory, it simply tells the autoloader that app/lib/MyCompany
is the root for the MyCompany\
namespace.
You would then be able to use the class as \MyCompany\Utility\Logger
.
Note that in PSR-4, unlike PSR-0, you'd normally omit MyCompany
from the directory structure, and just use app/lib/
.