Explain Constructor Injection ?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is eloquent model?

529


How to generate application key in laravel?

546


Tell me what are pros and cons of using laravel framework?

543


How auth is used?

552


What are the Forms in Laravel ?

894


List some features of laravel 5.0?

507


What is system requirement for installation of laravel 5.2 (latest version)?

516


What are enhancement features in laravel 5.8?

478


How to start valet?

523


What getfacadeaccessor method does?

570


What is a Laravel - Contracts ?

995


What is an observer in laravel?

533


What is x-csrf-token?

642


What is a check method ?

847


Does laravel passport use jwt?

537