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

Which file is used to create a connection with the database?

0 Answers  


What is orm framework?

0 Answers  


What are service providers in laravel?

0 Answers  


What is dd() function in laravel?

0 Answers  


Why laravel over other php frameworks?

0 Answers  


Tell me what is system requirement for installation of laravel 5.2 (latest version)?

0 Answers  


How to do environment configuration in laravel.

0 Answers  


How can we handle Error Handling in Laravel ?

1 Answers  


How to remove a complied class file?

0 Answers  


Explain laravel query builder?

0 Answers  


What are the benefits of facades?

0 Answers  


How to stop valet?

0 Answers  


Categories