Reputation: 103
i write a package manager for Laravel without need to Packagist. but every time a module added, need to run:
composer dump-autoload
in terminal.
how to automate load new module.
Upvotes: 0
Views: 1816
Reputation: 5874
There are many options for you to setup composer's autoload behaviours.
I'd recommend using psr-4
autoloading, for example:
...
"autoload": {
// The rest of your composer autoload
// add your namespace below
"psr-4": [
"Foo\\" : "app/Foo"
]
},
...
What this does is simply telling composer that you are following PSR-0/PSR-4 convention on structuring your folder/directory according to your namespace. You'll need to do composer dump-autoload
for this to work the first time, but it'll pick new modules up automatically the next time without dump-autoload
.
Read more on PSR guidelines here: PSR-0 and PSR-4
Amazing laracasts by Jeffrey Way: https://laracasts.com/lessons/psr-4-autoloading
Upvotes: 1