AdapterRegistry - viames/pair GitHub Wiki
Pair framework: AdapterRegistry
Pair\Core\AdapterRegistry is the process-local registry used by Pair v4 to hold explicitly configured adapters.
It is intentionally small. It is not a dependency injection container and it does not discover services automatically.
It is the adapter store commonly used by Runtime Extensions. Runtime Extensions are explicit bootstrap registrations through RuntimeExtensionInterface, while Installable Packages are ZIP/manifest packages handled by InstallablePackage and InstallablePackageRecord.
Typical usage
use Pair\Core\AdapterKeys;
use Pair\Core\Application;
$app = Application::getInstance();
$app->setAdapter(AdapterKeys::PAYMENTS, $stripeGateway);
$payments = $app->adapter(AdapterKeys::PAYMENTS, StripeGateway::class);
Use require(...) when the application cannot continue without that adapter:
$payments = $app->adapters()->require(AdapterKeys::PAYMENTS, StripeGateway::class);
Methods
set(string $name, object $adapter): void
Registers or replaces one adapter under a normalized capability name.
Names must be explicit stable keys such as:
cachemailerobservabilitypaymentsnotificationsaiui
The conventional names are available through Pair\Core\AdapterKeys.
get(string $name, ?string $expectedType = null): ?object
Returns the adapter or null.
When $expectedType is provided, the adapter must implement or extend that class/interface.
require(string $name, ?string $expectedType = null): object
Returns the adapter or throws a RuntimeException when it has not been registered.
has(string $name): bool
Returns whether a capability has a registered adapter.
remove(string $name): void
Removes one adapter.
clear(): void
Removes every registered adapter.
Design constraints
- Adapters are registered manually from application bootstrap or a Runtime Extension implementing
RuntimeExtensionInterface. - There is no automatic package discovery.
- Provider SDKs remain optional and should live in extension packages.
- Type checks are explicit through the optional
$expectedTypeargument.
See also: Application, RuntimeExtensionInterface, UiRenderer, Observability, Cache.