Laravel Service Container: Service Container: Tagging

Service Container: Tagging

Once the services have been tagged, you may easily resolve them all via the tagged method.

$this->app->bind('SpeedReport', function () {
    //
});

$this->app->bind('MemoryReport', function () {
    //
});

$this->app->tag(['SpeedReport', 'MemoryReport'], 'reports');
$this->app->bind('ReportAggregator', function ($app) {
    return new ReportAggregator($app->tagged('reports'));
});

Related concepts

Service Container: Tagging

Laravel Service Container: Service Container: Tagging — Structure map

Clickable & Draggable!

Laravel Service Container: Service Container: Tagging — Related pages: