league/container
PSR-11–compliant dependency injection container from The PHP League. Register services, factories and shared instances, then resolve dependencies with autowiring support. Modern PHP (8.3+) with full docs, tests, and MIT license.
OnDefineEvent, BeforeResolveEvent, DefinitionResolvedEvent, ServiceResolvedEventforType(), forTag(), forId(), where()Container::listen() for registering filtered event listenersContainer::afterResolve() convenience method as a drop-in replacement for inflector()EventDispatcher::hasListenersFor() to check whether listeners exist for a given event typeDefinitionInterface::getTags() for retrieving tags from definitionsContainer::getDelegate(string $class) to retrieve a registered delegate container by typeDefinition::resolveClass() now throws ContainerException with actionable guidance when a class has unsatisfied constructor dependencies, instead of a raw ArgumentCountErrorContainer::inflector() - use Container::afterResolve() or the event system instead. Will be removed in v6.0.DefinitionContainerInterface no longer extends EventAwareContainerInterface (removed)'shared' tag automatically via addTag('shared')EventAwareContainerInterface - the event system is provided by EventAwareTrait on the concrete Container class, not as an interface contract>=8.1>=7.2psr/container to ^2.0.0Container::shared convenience method is now explicit Container::addShared method$shared from Container::add, use Container::addSharedServiceProviderInterface now defines return typesprovides method rather than relying on a class property.psr/container ^2.0.0 as the interface cannot be reconciled between versionsregister call. @pcoutinhoReflectionContainer::call on arrow functions.$new argument when getting tagged definitions.{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\ContainerInterfacesetConcrete not re-resolving class on when overriding (@jleeothon){set|get}Concrete to definitions to allow for better use of extend.(Thanks to @jenssegers for these)
share proxy method that was mistakenly removed in previous major release.defaultToShared method.ReflectionContainer to cache resolutions and pull from cache for following calls.ReflectionContainer converts class name in array callable to object.RawArgument.RawArgument objects as first class dependencies.Container::get.Container::extend would not return a shared definition to extend.How can I help you explore Laravel packages today?