Core Registry
The central, globally accessible object registry, runtime class resolver and object lifecycle manager of APPNETOS.
Overview
Core\Registry is one of the few static classes in APPNETOS.
It provides the platform-wide entry point for resolving, creating,
registering and retrieving managed runtime objects.
Unlike an ordinary object container, it incorporates the active
application class mappings, class extensions, autowiring and shared
object lifecycle rules.
Once the system bootstrap has initialized the Registry, APPNETOS-managed
objects should be requested through its API. Instantiating those classes
directly with new bypasses Registry class resolution,
property autowiring and registration.
Implementation: appnetos/shared/src/Core/Registry.php
Bootstrap Integration
The system bootstrap initializes the Registry after Class Extension, Class Mapping and Error Handling bootstrap stages. At that point the runtime state contains the class mapping and extension information required for consistent object resolution.
Registry::init() reads both mappings from
Bootstrap\Runtime\RuntimeStateHolder, resets its object
stores and marks the Registry as initialized. Initialization is
idempotent during the runtime lifecycle. The Registry does not
perform the earlier bootstrap stages itself.
The implementation also contains a lazy initialization safeguard. Calling the Registry before the intended bootstrap sequence is not a substitute for preparing the required runtime state.
Class Resolution
resolveClass() first applies an application class mapping,
then selects the configured class extension for the mapped class or,
where applicable, the originally requested class. The extension
bootstrap has already prepared the effective extension class names.
The requested, mapped and extended class names are used to maintain consistent registry aliases. Class Mapping and Class Extension only apply when object creation is routed through the Registry.
Object Lifecycle
get() reuses an eligible shared or registered object, or
creates and registers a new one. getNew() creates a fresh
instance for non-shared classes and does not register it unless
requested. For classes marked #[Shared], both methods
respect the shared instance lifecycle.
New objects are constructed from the resolved runtime class and then processed by APPNETOS property autowiring. The Registry maintains the latest registered object per class key and a separate registration history. Shared instances may appear under multiple aliases without representing multiple physical objects.
getNew() instances are not registered by default.
Public API Overview
The Registry exposes 17 public static methods. This overview lists the supported operations by responsibility. Full signatures, parameter descriptions, return types and exceptions belong to the generated class reference based on source DocBlocks.
| Responsibility | Methods | Description |
|---|---|---|
| Initialization & Resolution | init(), resolveClass() |
Load mappings and extensions from the runtime state and resolve the effective runtime class. |
| Object Creation & Retrieval | get(), getNew(), getTyped(), getNewTyped() |
Retrieve an eligible registered or shared object, or create a new one. Typed variants execute within the requested autoload type. |
| Object Registration & Management | add(), set(), replace(), rebuild(), remove() |
Register objects, replace or rebuild instances, and remove related registry entries. |
| Registry Inspection | has(), getAll(), getAllTyped(), getObjects(), getSharedObjects() |
Inspect registration state, histories and shared entries. |
| Lifecycle Maintenance | clearCollectionDocuments() |
Clear in-memory document tracking in instantiated shared collections without resetting database connections or shared services. |
Best Practices & Restrictions
- Use
Registry::get()for managed, reusable runtime objects. - Use
Registry::getNew()when a new non-shared instance is required; request registration explicitly when needed. - Use the typed variants when a particular autoload type must be active for resolution.
- Do not use direct
newfor objects that must participate in APPNETOS Class Mapping, Class Extension or Registry autowiring. Core\Registrycannot be replaced through Class Mapping or Class Extension, and it cannot be requested as a Registry-managed object.clearCollectionDocuments()clears in-memory collection document tracking; it does not clear Redis or MongoDB state.