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 are contracts?

0 Answers  


What are view composers?

0 Answers  


How to know laravel version?

1 Answers  


How to check composer is installed or not in laravel?

0 Answers  


How to configure route cache and clear route cache in laravel?

0 Answers  


What is dd() function in laravel?

0 Answers  


What is lumen?

0 Answers  


What is a laravel model?

0 Answers  


How can you display html with blade in laravel?

0 Answers  


What is guard in laravel authentication?

0 Answers  


How to use joins in laravel?

0 Answers  


What is the difference between echo print print_r and var_dump?

0 Answers  


Categories