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 are the major differences between laravel 4 and laravel 5.x?

393


What are traits in laravel?

470


List basic concepts in laravel?

416


Which template engine laravel use?

454


Tell me what are system requirement for laravel 5.0?

406






How to list all routes in laravel?

428


What is algolia search?

392


What are the difference between insert() and insertgetid() in laravel?

521


What is blade php in laravel?

476


What are bundles, reverse routing and the ioc container?

375


How can I learn laravel fast?

416


What are common http error codes?

440


What is artisan in laravel?

408


What is route in laravel?

451


Explain how to do environment configuration in laravel?

418