Explain Constructor Injection ?



Explain Constructor Injection ?..

Answer / rachana devi

The Laravel service container is used to resolve all Laravel controllers.
As a result, you are able to type-hint any dependencies your controller may need in its constructor.
The dependencies will automatically be resolved and injected into the controller instance.

Example :

class MyClass
{
public $foo = 'bar';
}
Route::get('/myclass','ImplicitController@index');


we have to Add the following code to app/Http/routes.php file. "app/Http/routes.php".

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Laravel PHP Framework Interview Questions

What is best backend framework?

0 Answers  


Tell me what is database migration? And how to use it to add insert initial data to database?

0 Answers  


How to generate a controller with resources in laravel?

0 Answers  


How do I use sub-domain routing?

0 Answers  


What is meant by Laravel - Ajax ?

1 Answers  






What is report method?

0 Answers  


What is a Encryption Process ?

0 Answers  


What is meant by Authorization Mechanism in Laravel ?

1 Answers  


What are Global Middleware and Route Middleware ?

0 Answers  


By default valet serve your app which tld? On how to configure it to use another domain?

0 Answers  


What is the make method?

0 Answers  


Tell me how to enable maintenance mode in laravel 5?

0 Answers  


Categories