adspace


Tell me how do you do dependency injection in laravel?

Answer Posted / Uttam Kumar

"Dependency Injection is accomplished in Laravel through the use of the service container. To bind a class as a service, you can utilize the IoC container with the `bind`, `singleton`, or `instance` methods. For example:nn<code>// Bind a class as a singletonn$app->singleton('AppServicesMyService', function () {n return new AppServicesMyService();n});</code>"

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is current stable version of laravel?

870


How much laravel experience do you have?

815


Tell us have you used lumen before?

808


Do you know what version of laravel do you generally use?

839


What is latest version of laravel?

869