Include class usning psr4 autoload vs includ class using namespace in laravel

34 Views Asked by At

I am using laravel. I created Orders folder in app directory and created class Payments. I added that class by namespace into my controller (by using phpstorm suggestions) and It worked fine.

Now my question is why do we use composer psr-4 autoload if we can add classes directly using namespace? Following is composer psr-4 autoload example

"psr-4": {
            "App\\": "app/",
            "Orders\\": "app/Orders",
        }

Now what is the benifit of adding my module folder in psr-4 autoload because I can add classes without psr-4 autoload?

0

There are 0 best solutions below