Skip to content

Releases: thephpleague/container

5.2.0

19 Mar 18:54

Choose a tag to compare

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

5.1.0

28 May 07:40

Choose a tag to compare

5.1.0

Added

Changed

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

5.0.1

27 Mar 09:34

Choose a tag to compare

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

4.2.4

10 Nov 12:43

Choose a tag to compare

4.2.4

Fixed

  • Now properly handle string based fully qualified class names in with preceding slashes. (@M1ke)

4.2.3

23 Oct 12:08

Choose a tag to compare

Fixed

  • Warnings for PHP 8.4 implicit nullable types (@andypost)

4.2.1

13 Mar 11:06

Choose a tag to compare

4.2.1

Fixed

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

4.2.0

16 Nov 10:30

Choose a tag to compare

Added

  • Support for psr/container 1.1.0.

4.1.2

26 Jul 07:05

Choose a tag to compare

Fixed

  • Fix bug that was causing an error on inflection due to introduced type hint.

4.1.1

09 Jul 13:40

Choose a tag to compare

Changed

  • Move files autoload directive to dev (@ADmad)

4.1.0

09 Jul 09:28

Choose a tag to compare

Added

  • Way to handle non-public controllers safely (@beryllium)