F
F
FMars2015-04-05 20:02:51
Laravel
FMars, 2015-04-05 20:02:51

Laravel 5. Service provider in Laravel, what is it for?

Do I understand correctly that the main task of a service provider is to implement the scheme - "one interface, many implementations"? That is, we make a bind whose key corresponds to some interface, and pass the implementation class itself as the second parameter.

$this->app->bind('App\Contracts\Article', 'App\Services\ArticleEloquent');

This is the main purpose of the provider?
+ Service containers are, roughly speaking, just the code with which we bind or not?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JhaoDa, 2015-04-05
@FMars

No, this is one of the features. The purpose of the provider is to centrally connect and initialize the necessary application components (via bind, share, singleton - it doesn’t matter), as well as perform other global (within the application) tasks.

A
Alexey, 2015-04-05
@xelam

maybe this will help? onedev.net/post/539

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question