I apologize if this is duplicate; please guide me to the right directions.
I know we can create class aliases in Laravel from /config/app.php
. However tryin
Make your code PSR-4 compatible and put it in composer.json
"autoload": {
"psr-4": {
"MyNamespace\\": "src/MyNameSpace",
}
},
Then run composer dumpautoload
. So long as you stick to the convention of subfolders being namespaces, your classes will autoload.
src/MyNamespace/SomeClass.php
would have namespace MyNamespace;
and class SomeClass
.
src/MyNamespace/Something/SomethingElse.php
would have namespace MyNamespace\Something;
and class SomethingElse
.