webwinner
webwinner

Reputation: 87

Service Container is the same Dependency Injection in symfony?

In symfony framework service's is the same depedency injection ?

What is the difference beetwen service container as Dependency Injection ?

Upvotes: 0

Views: 438

Answers (3)

Isaac
Isaac

Reputation: 1525

You could probably quibble with this but:

  • Dependency injection is a design pattern that you use when writing classes, in which depended upon objects are injected into the instance using a constructor or setter. It is more a concept that you use when thinking about how to write code, but doesn't do anything by itself.
  • A service container is an actual thing that is instantiated and creates objects for use in your application. Use of a SC is a design pattern, but the SC is itself instantiated and does things for your application.
  • They are related in that the usefulness of a Service Container is (imo) maximized when it is creating objects that leverage the concept of Dependency Injection.

Upvotes: 0

miltone
miltone

Reputation: 4721

service container as Dependency Injection is a concept for applications developer. Each langugage paradigm as Java, Python or PHP has a service container (DI for Dependency Injection).

For the framework PHP Symfony it tells that Service Container (or just service). In DI concept you can easily delete the contain. It's a obviousness. Because all DI (Java, Python, etc...) live into a container or just a context.

If you already know language that Java and You want to know how symfony manage DI then I just says :"the service" in symfony is the concept of DI for this framework in PHP language.

You can read this post : What is Dependency Injection

Upvotes: 1

Kep
Kep

Reputation: 5857

There's pretty much a direct answer in the Symfony docs:

The DependencyInjection component implements a PSR-11 compatible service container that allows you to standardize and centralize the way objects are constructed in your application.

Also, take a look at the Service Container docs.

Upvotes: 0

Related Questions