A Dependency Injector Container in Your Project

Video loading...

  • 0:00
    DEPENDENCY INJECTION AND THE ART OF SERVICES AND CONTAINERS
  • 0:01
    A Dependency Injector Container in Your Project
  • 0:03
    with Leanna Pelham
  • 0:08
    OK, time to get emailing.
  • 0:10
    No matter what framework or system you work on,
  • 0:12
    you can start applying these principles immediately.
  • 0:15
    You may already have a dependency injection container
  • 0:18
    available to you, and if so, great.
  • 0:21
    If not, don't worry.
  • 0:22
    Even without a container, you can start applying the principles
  • 0:26
    of moving code into new service classes
  • 0:28
    and using dependency injection.
  • 0:31
    If you have to instantiate these service objects immediately
  • 0:34
    when you need them, that's still a huge step forward.
  • 0:38
    You can also bring a container into your project.
  • 0:40
    Pimple is the simplest and easiest, but there are also
  • 0:43
    others, such as Symfony's Dependency Injection Component, Aura Di
  • 0:48
    and ZendDi. These are more feature rich
  • 0:50
    and also contain speed optimizations.
  • 0:53
    Somewhere early in your bootstrap process,
  • 0:55
    simply create the container, configure it,
  • 0:58
    and make it available to your controllers or page code.
  • 1:01
    If you have any questions or comments, post them.
  • 1:04
    Have fun, and we'll see you next time.

A Dependency Injector Container in Your Project

Loading...

Now it's time for you to use dependency injection containers in your own projects. In this tutorial we talk briefly about some other containers out there you might want to check out.

If you'd like to dive deeper into Dependency Injection containers, you should check out KnpUniversity's full series, Journey to the Center of Symfony: The Dependency Injection Container.

Downloads: 
Log in or sign up to download companion files.
Additional resources: 

To learn how to apply these concepts in Drupal 8 module development, check out the Module Development Essentials series, starting with Understand the Service Container.