PackageTrack
Sign in Get early access

league/container

A fast and intuitive dependency injection container.

5.2.0 98M downloads/mo #438 most downloaded on Packagist thephpleague/container

What this package is like to depend on

Last release 5 months ago

19 Mar 2026

Ships unpredictably

gaps range from 2 weeks to 2.3 years

Nearly every release is documented

notes for 42 of 46 stable releases

Nothing withdrawn

no release was ever pulled

12 years old

46 releases · first in 2015

1 release in the last 12 months

see the full history below

Release timeline

46 releases · Jan 2015 to Mar 2026
2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026
Release Pre-release

Releases

latest 46
  1. 5.2.0 19 Mar 2026
    Release notes

    5.2.0

    Added

    • Event system for hooking into the container lifecycle
      • Four event types: OnDefineEvent, BeforeResolveEvent, DefinitionResolvedEvent, ServiceResolvedEvent
      • Fluent filtering API: forType(), forTag(), forId(), where()
      • Container::listen() for registering filtered event listeners
      • Container::afterResolve() convenience method as a drop-in replacement for inflector()
      • Lazy event dispatch: events are only created when listeners are registered for that event type
      • EventDispatcher::hasListenersFor() to check whether listeners exist for a given event type
      • DefinitionInterface::getTags() for retrieving tags from definitions
      • Docs: https://container.thephpleague.com/5.x/events/
    • Container::getDelegate(string $class) to retrieve a registered delegate container by type

    Fixed

    • Interface-to-concrete definitions now correctly resolve through the concrete's own registered definition instead of bypassing it via direct reflection (#275, #278)
    • Definition::resolveClass() now throws ContainerException with actionable guidance when a class has unsatisfied constructor dependencies, instead of a raw ArgumentCountError

    Deprecated

    • Container::inflector() - use Container::afterResolve() or the event system instead. Will be removed in v6.0.

    Changed

    • DefinitionContainerInterface no longer extends EventAwareContainerInterface (removed)
    • Shared definitions now receive a 'shared' tag automatically via addTag('shared')

    Removed

    • EventAwareContainerInterface - the event system is provided by EventAwareTrait on the concrete Container class, not as an interface contract
    Open source →
    Release notes

    Added

    • Event system for hooking into the container lifecycle
      • Four event types: OnDefineEvent, BeforeResolveEvent, DefinitionResolvedEvent, ServiceResolvedEvent
      • Fluent filtering API: forType(), forTag(), forId(), where()
      • Container::listen() for registering filtered event listeners
      • Container::afterResolve() convenience method as a drop-in replacement for inflector()
      • Lazy event dispatch: events are only created when listeners are registered for that event type
      • EventDispatcher::hasListenersFor() to check whether listeners exist for a given event type
      • DefinitionInterface::getTags() for retrieving tags from definitions
      • Docs: https://container.thephpleague.com/5.x/events/
    • Container::getDelegate(string $class) to retrieve a registered delegate container by type

    Fixed

    • Interface-to-concrete definitions now correctly resolve through the concrete's own registered definition instead of bypassing it via direct reflection (#275, #278)
    • Definition::resolveClass() now throws ContainerException with actionable guidance when a class has unsatisfied constructor dependencies, instead of a raw ArgumentCountError

    Deprecated

    • Container::inflector() - use Container::afterResolve() or the event system instead. Will be removed in v6.0.

    Changed

    • DefinitionContainerInterface no longer extends EventAwareContainerInterface (removed)
    • Shared definitions now receive a 'shared' tag automatically via addTag('shared')

    Removed

    • EventAwareContainerInterface - the event system is provided by EventAwareTrait on the concrete Container class, not as an interface contract
    Open source →
    Release notes

    5.2.0 Latest

    Latest

    Compare

    Choose a tag to compare

    Open source →
  2. 5.1.0 28 May 2025
    Release notes

    5.1.0

    Added

    Changed

    • Small internal changes for stricter static analysis and type safety. (@ADmad)
    Open source →
    Release notes

    Added

    Changed

    • Small internal changes for stricter static analysis and type safety. (@ADmad)

    5.0.1

    Fixed

    • Fixed a small unreachable code bug
    Open source →
    Release notes

    5.1.0

    Compare

    Choose a tag to compare

    Open source →
  3. 5.0.1 27 Mar 2025
    Release notes

    5.0.1

    Fixed

    • Fixed a small unreachable code bug

    5.0.0

    Added

    • Ability to overwrite a definition within the container, disabled by default

    Changed

    • PHP requirement now >=8.1
    • General language modernisation
    • General prep for future updates and container compilation
    Open source →
    Release notes

    5.0.1

    Compare

    Choose a tag to compare

    Open source →
  4. 5.0.0 27 Mar 2025
    Release notes

    Added

    • Ability to overwrite a definition within the container, disabled by default

    Changed

    • PHP requirement now >=8.1
    • General language modernisation
    • General prep for future updates and container compilation
    Open source →
    Release notes

    Added

    • Ability to overwrite a definition within the container, disabled by default

    Changed

    • PHP requirement now >=8.1

    • General language modernisation

    • General prep for future updates and container compilation

    Assets 2 Loading

    Uh oh!

    There was an error while loading. Please reload this page .

    👍 1 dragomano reacted with thumbs up emoji All reactions

    • 👍 1 reaction

    1 person reacted

    Open source →
  5. 4.2.5 20 May 2025

    Nothing published for this version

  6. 4.2.4 10 Nov 2024
    Release notes

    4.2.4

    Fixed

    • Now properly handle string based fully qualified class names in with preceding slashes. (@M1ke)
    Open source →
    Release notes

    Fixed

    • Now properly handle string based fully qualified class names in with preceding slashes. (@M1ke)
    Open source →
    Release notes

    4.2.4

    Compare

    Choose a tag to compare

    Open source →
  7. 4.2.3 23 Oct 2024
    Release notes

    Fixed

    • Warnings for PHP 8.4 implicit nullable types (@andypost)
    Open source →
    Release notes

    Fixed

    • Warnings for PHP 8.4 implicit nullable types (@andypost)
    Open source →
    Release notes

    4.2.3

    Compare

    Choose a tag to compare

    Open source →
  8. 4.2.2 13 Mar 2024

    Nothing published for this version

  9. 4.2.1 13 Mar 2024
    Release notes

    4.2.1

    Fixed

    • Remove an unnecessary conditional in ServiceProviderAggregate. (@Subhansh)
    • Fixed an infinite loop in resolving definitions. (@arai-ta)
    Open source →
    Release notes

    Fixed

    • Remove an unnecessary conditional in ServiceProviderAggregate. (@SubhanSh)
    • Fixed an infinite loop in resolving definitions. (@arai-ta)
    Open source →
    Release notes

    4.2.1

    Compare

    Choose a tag to compare

    Open source →
  10. 4.2.0 16 Nov 2021
    Release notes

    Added

    • Support for psr/container 1.1.0.
    Open source →
    Release notes

    Added

    • Support for psr/container 1.1.0.
    Open source →
    Release notes

    4.2.0

    Compare

    Choose a tag to compare

    Open source →
  11. 4.1.2 26 Jul 2021
    Release notes

    Fixed

    • Fix bug that was causing an error on inflection due to introduced type hint.
    Open source →
    Release notes

    4.1.2

    Compare

    Choose a tag to compare

    Open source →
  12. 4.1.1 09 Jul 2021
    Release notes

    Changed

    • Move files autoload directive to dev (@ADmad)
    Open source →
    Release notes

    4.1.1

    Compare

    Choose a tag to compare

    Open source →
  13. 4.1.0 09 Jul 2021
    Release notes

    Added

    • Way to handle non-public controllers safely (@beryllium)
    Open source →
    Release notes

    4.1.0

    Compare

    Choose a tag to compare

    Open source →
  14. 4.0.0 09 Jul 2021
    Release notes

    Added

    • New definition interface that extends psr/container
    • Literal and resolvable argument wrappers for better explicitness in definitions

    Changed

    • PHP requirement now >=7.2
    • Updated psr/container to ^2.0.0
    • Container::shared convenience method is now explicit Container::addShared method
    • Removed third argument $shared from Container::add, use Container::addShared
    • ServiceProviderInterface now defines return types
    • Service providers now require implementation of a provides method rather than relying on a class property.
    Open source →
  15. 3.4.1 09 Jul 2021
    Release notes

    Added

    • Way to handle non-public controllers safely (@beryllium)
    • PHPUnit ^7.0 for PHP versions that support it (@beryllium)
    Open source →
  16. 3.4.0 09 Jul 2021
    Release notes

    Removed

    • Support for psr/container ^2.0.0 as the interface cannot be reconciled between versions
    Open source →
  17. 3.3.5 16 Mar 2021
    Release notes

    Added

    • Support for psr/container ^2.0.0
    Open source →
  18. 3.3.4 22 Feb 2021
    Release notes

    Fixed

    • Fixed an issue that caused a recursive register call. @pcoutinho
    • Fixed a return type declaration. @orbex
    Open source →
  19. 3.3.3 28 Sep 2020
    Release notes

    Fixed

    • Fixed bug relating to ReflectionContainer::call on arrow functions.
    Open source →
  20. 3.3.2 26 Sep 2020
    Release notes

    Added

    • Experimental support for PHP 8.

    Fixed

    • Fix issue when preventing reflection from using default value for arguments.
    Open source →
  21. 3.3.1 18 May 2020
    Release notes

    Fixed

    • Respect $new argument when getting tagged definitions.
    Open source →
  22. 3.3.0 30 Jun 2019
    Release notes

    Added

    • Support for PHP 7.3
    • {set,get}LeagueContainer methods added to ContainerAwareTrait as a temporary measure until next major release when this can be properly addressed, less hinting of Psr\Container\ContainerInterface

    Changed

    • Various internal code improvements

    Fixed

    • Fix for setConcrete not re-resolving class on when overriding (@jleeothon)
    • Fix stack overflow error incase a service provider lies about providing a specific service (@azjezz)
    • Fix issue where providers may be aggregated multiple times (@bwg)
    • Various documentation fixes
    Open source →
  23. 3.2.2 28 Sep 2018
    Release notes

    Fixed

    • Fixed issue that prevented service providers from registering if a previous one in the aggregate was already registered.
    Open source →
  24. 3.2.1 21 Sep 2018
    Release notes

    Fixed

    • Fixed issue where all service providers were registered regardless of whether they need to be.
    Open source →
  25. 3.2.0 13 Aug 2018
    Release notes

    Added

    • Added ability to add definition as not shared when container is set to default to shared.
    • Added {set|get}Concrete to definitions to allow for better use of extend.
    Open source →
  26. 3.1.0 12 Aug 2018
    Release notes

    Added

    • Re-added the share proxy method that was mistakenly removed in previous major release.
    • Added ability to set Container to "share" by default using defaultToShared method.
    • Added ability for ReflectionContainer to cache resolutions and pull from cache for following calls.
    Open source →
  27. 3.0.1 25 Jul 2018
    Release notes

    Added

    • Allow definition aggregates to be built outside of container.
    Open source →
  28. 3.0.0 23 Jul 2018
    Release notes

    Added

    • Service providers can now be pulled from the container if they are registered.
    • Definition logic now handled by aggregate for better separation.
    • Now able to add tags to a definition to return an array of items containing that tag.

    Changed

    • Updated minimum PHP requirements to 7.0.
    • Now depend directly on PSR-11 interfaces, including providing PSR-11 exceptions.
    • Refactored inflector logic to accept type on construction and use generator to iterate.
    • Refactored service provider logic with better separation and performance.
    • Merged service provider signature logic in to one interface and abstract.
    • Heavily simplified definition logic providing more control to user.
    Open source →
  29. 2.5.0 22 Feb 2021

    Nothing published for this version

  30. 2.4.1 10 May 2017
    Release notes

    Fixed

    • Ensures ReflectionContainer converts class name in array callable to object.
    Open source →
  31. 2.4.0 06 Mar 2017
    Release notes

    Changed

    • Can now wrap shared objects as RawArgument.
    • Ability to override shared items.

    Fixed

    • Booleans now recognised as accepted values.
    • Various docblock fixes.
    • Unused imports removed.
    • Unreachable arguments no longer passed.
    Open source →
  32. 2.3.0 17 Feb 2017
    Release notes

    Added

    • Now implementation of the PSR-11.
    Open source →
  33. 2.2.0 17 Mar 2016
    Release notes

    Changed

    • Service providers can now be added multiple times by giving them a signature.
    Open source →
  34. 2.1.0 15 Mar 2016
    Release notes

    Added

    • Allow resolving of RawArgument objects as first class dependencies.

    Changed

    • Unnecessary recursion removed from Container::get.
    Open source →
  35. 2.0.3 07 Sep 2015
    Release notes

    Fixed

    • Bug where delegating container was not passed to delegate when needed.
    • Bug where Container::extend would not return a shared definition to extend.
    Open source →
  36. 2.0.2 03 Sep 2015
    Release notes

    Fixed

    • Bug introduced in 2.0.1 where shared definitions registered via a service provider would never be returned as shared.
    Open source →
  37. 2.0.1 02 Sep 2015
    Release notes

    Fixed

    • Bug where shared definitions were not stored as shared.
    Open source →
  38. 2.0.0 02 Sep 2015
    Release notes

    Added

    • Now implementation of the container-interop project.
    • BootableServiceProviderInterface for eagerly loaded service providers.
    • Delegate container functionality.
    • RawArgument to ensure scalars are not resolved from the container but seen as an argument.

    Altered

    • Refactor of definition functionality.
    • Container::share replaces singleton functionality to improve understanding.
    • Auto wiring is now disabled by default.
    • Auto wiring abstracted to be a delegate container ReflectionContainer handling all reflection based functionality.
    • Inflection functionality abstracted to an aggregate.
    • Service provider functionality abstracted to an aggregate.
    • Much bloat removed.
    • Container::call now proxies to ReflectionContainer::call and handles argument resolution in a much more efficient way.

    Removed

    • Ability to register invokables, this functionality added a layer of complexity too large for the problem it solved.
    • Container no longer accepts a configuration array, this functionality will now be provided by an external service provider package.
    Open source →
  39. 1.3.2 05 Apr 2015

    Nothing published for this version

  40. 1.3.1 21 Feb 2015
    Release notes

    Fixed

    • Fixed bug where arbitrary values were attempted to be resolved as classes.
    Open source →
  41. 1.3.0 09 Feb 2015
    Release notes

    Added

    • Added ServiceProvider functionality to allow cleaner resolving of complex dependencies.
    • Added Inflector functionality to allow for manipulation of resolved objects of a specific type.
    • Improvements to DRY throughout the package.

    Fixed

    • Setter in ContainerAwareTrait now returns self ($this).
    Open source →
  42. 1.2.1 29 Jan 2015
    Release notes

    Fixed

    • Allow arbitrary values to be registered via container config.
    Open source →
  43. 1.2.0 13 Jan 2015
    Release notes

    Added

    • Improvements to Container::call functionality.

    Fixed

    • General code tidy.
    • Improvements to test suite.
    Open source →
  44. 1.1.1 13 Jan 2015
    Release notes

    Fixed

    • Allow singleton to be passed as method argument.
    Open source →
  45. 1.1.0 12 Jan 2015
    Release notes

    Added

    • Addition of ContainerAwareTrait to provide functionality from ContainerAwareInterface.
    Open source →
  46. 1.0.0 12 Jan 2015
    Release notes

    Added

    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive