Neuron-PHP

Registry extends Memory
in package

Global object registry implementing the Registry design pattern.

This singleton registry provides centralized storage and retrieval of objects throughout the application lifecycle. It serves as a service locator and dependency injection container, allowing components to share state and communicate across the entire framework.

Tags
example
$registry = Registry::instance();

// Store configuration (method syntax)
$registry->set('database.config', $dbConfig);
$registry->set('app.settings', $appSettings);

// Store configuration (property syntax using magic methods)
$registry->databaseConfig = $dbConfig;
$registry->appSettings = $appSettings;

// Retrieve objects (method syntax)
$dbConfig = $registry->get('database.config');

// Retrieve objects (property syntax using magic methods)
$dbConfig = $registry->databaseConfig;

// Check existence
$exists = isset($registry->databaseConfig);

// Cleanup
$registry->reset(); // Clear all objects

Table of Contents

Properties

$_instance  : mixed
$_objects  : array<string|int, mixed>

Methods

__construct()  : mixed
__get()  : mixed
Magic method to get a registry value using property syntax.
__isset()  : bool
Magic method to check if a registry key exists using isset().
__set()  : void
Magic method to set a registry value using property syntax.
get()  : mixed
getInstance()  : ISingleton|null
instance()  : mixed
Gets the global object instance.
invalidate()  : void
Clears the current global object.
reset()  : void
serialize()  : void
Writes the object data to the storage medium.
set()  : void

Properties

$_instance

public static mixed $_instance = []

$_objects

private array<string|int, mixed> $_objects = []

Methods

__construct()

public __construct() : mixed

__get()

Magic method to get a registry value using property syntax.

public __get(string $name) : mixed
Parameters
$name : string

The name of the registry key

Return values
mixed

The value stored in the registry, or null if not found

__isset()

Magic method to check if a registry key exists using isset().

public __isset(string $name) : bool
Parameters
$name : string

The name of the registry key

Return values
bool

True if the key exists in the registry, false otherwise

__set()

Magic method to set a registry value using property syntax.

public __set(string $name, mixed $value) : void
Parameters
$name : string

The name of the registry key

$value : mixed

The value to store in the registry

get()

public get(string $name) : mixed
Parameters
$name : string

instance()

Gets the global object instance.

public static instance() : mixed

invalidate()

Clears the current global object.

public static invalidate() : void

serialize()

Writes the object data to the storage medium.

public serialize() : void

set()

public set(mixed $name, mixed $object) : void
Parameters
$name : mixed
$object : mixed

        
On this page

Search results