Does dependency injection in laravel controller slow down application performance?

Viewed 39

I am not a computer science background student. So I have no idea how much space complexity created by calling a laravel controller method. From a senior developer podcast I came to know that every variable, function, class created by us in program take space in memory.

Now from this perspective, my confusion is ----

when I call a controller method of laravel for a route, laravel create a instance of whole controller class. But I use only one method that time. Here other methods remain unused.

Some time I create service class or repository class in __construct method of controller as dependency injection. Same case there. For calling one method of service or repository class I am instantiating the whole service or repository class every time.

Is not it a bad impact on performance issue of application? If so, what is the solution ?

0 Answers
Related