Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Container Laravel Package

league/container

league/container is a lightweight PSR-11 dependency injection container for PHP. Define entries, factories, and autowiring-friendly services to manage application dependencies cleanly, with modern PHP support and solid tooling for testing and analysis.

View on GitHub
Deep Wiki
Context7

layout: post title: Delegate Containers sections: Introduction: introduction Usage: usage

Introduction

Delegate containers are a way to allow you to register one or multiple backup containers that will be used to attempt the resolution of services when they cannot be resolved via this container.

Usage

A delegate must be a PSR-11 implementation and can be registered using the delegate method.

<?php 

namespace Acme\Container;

use Psr\Container\ContainerInterface;

class DelegateContainer implements ContainerInterface
{
    // ..
}
<?php 

$container = new League\Container\Container();
$delegate  = new Acme\Container\DelegateContainer();

// this method can be invoked multiple times, each delegate
// is checked in the order that it was registered
$container->delegate($delegate);

Now that the delegate has been registered, if a service cannot be resolved via the primary container, it will resort to the has and get methods of the delegates to resolve the requested service.

Retrieving a Delegate

If you need to access a registered delegate later, use the getDelegate method with the delegate's class name.

<?php

$container = new League\Container\Container();

$container->delegate(
    new League\Container\ReflectionContainer()
);

$reflection = $container->getDelegate(League\Container\ReflectionContainer::class);

This is useful when you need to call delegate-specific methods that are not part of the PSR-11 interface, such as passing runtime arguments to ReflectionContainer::get() (see Auto Wiring).

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle