Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 462 Bytes

container-collector-pattern.md

File metadata and controls

20 lines (17 loc) · 462 Bytes

Data Collector Pattern

Register Singleton Collection

Register in a service provider.

$this->app->singleton('collector', fn()=>collect());

Register Terminate Callback

Register in a service provider. Send a http request or store in the database.

$this->app->terminating(function () {
    $data = $this->app->make('collector');
});

Push values into the collector.

app('collector')->push(['stats' => Str::random()]);