Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Sanjarbek Sobirjonov
Sanjarbek Sobirjonov

Posted on

     

Service container in Laravel

I'm confused about dependency injection. In the prior time, I haven't faced to dependency injection, to be honest, I haven't used it. What is it? Please, explain for me in simply words.

With regards,
Sanjarbek

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
hakobyansen profile image
Senik Hakobyan
Software Developer
  • Location
    Yerevan, Armenia
  • Work
    Senior Software Developer
  • Joined

In simple words: whenever you define a parameter in your class constructor - you define a dependency for that class, so that it can't be initialized without injecting (passing) dependencies that you have required in your constructor.

Laravel does it for you automatically unless you are not injecting abstractions, like interfaces. In those cases you can implement bindings in Service Providers.

Good luck! :)

CollapseExpand
 
sobirjonovs profile image
Sanjarbek Sobirjonov
CEO at Tutorials.uz
  • Location
    Uzbekistan
  • Education
    High School degree
  • Work
    Not employeed
  • Joined

Thank you!!! Got it!

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

CEO at Tutorials.uz
  • Location
    Uzbekistan
  • Education
    High School degree
  • Work
    Not employeed
  • Joined

More fromSanjarbek Sobirjonov

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp