I installed slim by composer my project directory structure is below,
i want to load my custom classes in src/app directory all class are having namespace app so that i can use them in routes how to do so please somebody help,
Get them autoloaded using composer:
You probally need to run composer dump-autoload after adding your classes.
thank you very much @svl will definitely try this.
It works like a charm… thanks
@SVL’s answer will work but limits you to only the namespaces/paths defined. You could simplify this a bit and automatically load everything in the
app folder under the
App namespace like so:
This would allow you to have any combination of folders under
app/ as long as you give your classes the proper namespace. For example:
@PHLAK thanks for the information. Do I need to run
composer update after this update to my composer.json?
@AhmadKarim Yes, you have to run
composer update after you’ve updated your
composer.json file. However, after that you should be able to add any number of new classes in the namespace you used without re-running