Singleton
Register a class as a singleton in the container
Description: Registers the class as a singleton in the container โ shared across the entire application lifecycle.
Namespace: Illuminate\Container\Attributes\Singleton
Usage
use Illuminate\Container\Attributes\Singleton;
#[Singleton]
class ConfigCache
{
private array $cache = [];
public function remember(string $key, callable $callback): mixed
{
return $this->cache[$key] ??= $callback();
}
}