Proxy System
ADP uses the proxy pattern to intercept PSR interface calls transparently. Proxies wrap standard PSR implementations and feed intercepted data to collectors without modifying application code.
How It Works
A proxy implements the same PSR interface as the original service. It delegates all calls to the real implementation while recording data for its paired collector.
Application Code
│
▼
┌─────────────────┐
│ PSR Interface │ ← Your code calls this normally
│ (e.g. Logger) │
└────────┬────────┘
│
┌────────▼────────┐
│ Proxy │ ← Intercepts + records
│ (LoggerProxy) │
└────────┬────────┘
│
┌────────▼────────┐
│ Real Service │ ← Original implementation
│ (Monolog, etc.) │
└────────┬────────┘
│
┌────────▼────────┐
│ Collector │ ← Receives recorded data
│ (LogCollector) │
└─────────────────┘Built-in Proxies
Kernel provides framework-independent PSR proxies:
Framework-Specific Proxies
Framework adapters provide additional proxies for interfaces that are not PSR-standardized:
Translator Proxies
Each framework has its own translator interface. ADP provides a dedicated proxy for each, all feeding the same TranslatorCollectorAppDevPanel\Kernel\Collector\TranslatorCollectorCaptures translation lookups during request execution.. See the Translator page for full details.
Symfony -- decorates TranslatorInterfaceSymfony\Contracts\Translation\TranslatorInterfaceSymfony Translation Contract. Translates messages using message catalogs. via setDecoratedService() in the compiler pass. Intercepts trans() calls.
Laravel -- decorates TranslatorIlluminate\Contracts\Translation\TranslatorLaravel Translator Contract. Provides translation services for the application. via $app->extend('translator'). Intercepts get() and choice() calls. Parses Laravel's dot-notation keys (group.key) into category and message.
Yii 3 -- registered in trackedServices alongside ValidatorInterfaceProxyAppDevPanel\Adapter\Yii3\Collector\Validator\ValidatorInterfaceProxyDecorator proxy for Validator Interface. Intercepts calls and forwards data to collectors.. Intercepts translate() calls. Supports withDefaultCategory() and withLocale() immutable methods.
Yii 2 -- extends yii\i18n\I18N and overrides translate(). Replaces the i18n application component during module bootstrap.
Missing translation detection
All proxies detect missing translations by comparing the translator's return value with the original message ID. If they are identical, the translation is marked as missing.
ProxyDecoratedCalls Trait
The ProxyDecoratedCalls trait provides __call, __get, and __set magic methods that delegate to the wrapped service. Proxies use this trait to forward any non-intercepted method calls transparently.
Proxy Registration
Proxies are registered by framework adapters through DI container configuration. The adapter replaces the original PSR service binding with the proxy, which wraps the original service:
// Simplified adapter DI configuration
LoggerInterface::class => function (ContainerInterface $c) {
return new LoggerInterfaceProxy(
$c->get(LogCollector::class),
$c->get('original.logger'),
);
},Key Principles
- Transparent -- Application code is unaware of interception
- Zero overhead when disabled -- Proxies are only registered when ADP is active
- PSR-compliant -- Proxies implement the exact same interface as the original service
- Colocated -- Each proxy lives alongside its paired collector in
src/Collector/