Monday, July 3, 2017

Laravel 5: Get Service Instance In Controller Dynamically | Get Service Instance In Service Dynamically

The Laravel service container is a powerful tool for managing class dependencies. Dependency injection is a fancy word that essentially means this: class dependencies are "injected" into the class via the constructor.

There are several ways to resolve something out of the container. First, you may use the make method as below example:

$service = app()->make("App\\Service\\EmployeeService");

So it makes life easier.

No comments:

Post a Comment