Skip to content

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:

ProxyPSR InterfacePaired Collector
LoggerInterfaceProxyAppDevPanel\Kernel\Collector\LoggerInterfaceProxyDecorator proxy for Logger Interface. Intercepts calls and forwards data to collectors.final Kernel · class · implements LoggerInterfacePSR-3 LoggerInterfacePsr\Log\LoggerInterfacePSR-3 Logger Interface. Describes a logger instance.PSR-3 · interfaceLogCollectorAppDevPanel\Kernel\Collector\LogCollectorCollects Log data during application lifecycle.Kernel · class · implements SummaryCollectorInterface
EventDispatcherInterfaceProxyAppDevPanel\Kernel\Collector\EventDispatcherInterfaceProxyDecorator proxy for Event Dispatcher Interface. Intercepts calls and forwards data to collectors.final Kernel · class · implements EventDispatcherInterfacePSR-14 EventDispatcherInterfacePsr\EventDispatcher\EventDispatcherInterfacePSR-14 Event Dispatcher Interface. Defines a dispatcher for events.PSR-14 · interfaceEventCollectorAppDevPanel\Kernel\Collector\EventCollectorCollects Event data during application lifecycle.final Kernel · class · implements SummaryCollectorInterface
HttpClientInterfaceProxyAppDevPanel\Kernel\Collector\HttpClientInterfaceProxyDecorator proxy for Http Client Interface. Intercepts calls and forwards data to collectors.final Kernel · class · implements ClientInterfacePSR-18 ClientInterfacePsr\Http\Client\ClientInterfacePSR-18 HTTP Client Interface. Sends PSR-7 requests and returns PSR-7 responses.PSR-18 · interfaceHttpClientCollectorAppDevPanel\Kernel\Collector\HttpClientCollectorCollects Http Client data during application lifecycle.final Kernel · class · implements SummaryCollectorInterface

Framework-Specific Proxies

Framework adapters provide additional proxies for interfaces that are not PSR-standardized:

ProxyFrameworkInterfacePaired Collector
SymfonyTranslatorProxyAppDevPanel\Adapter\Symfony\Proxy\SymfonyTranslatorProxyDecorates Symfony's TranslatorInterface to feed translation lookups to TranslatorCollector.final Adapter/Symfony · class · implements TranslatorInterfaceSymfonyTranslatorInterfaceSymfony\Contracts\Translation\TranslatorInterfaceSymfony Translation Contract. Translates messages using message catalogs.Symfony · interfaceTranslatorCollectorAppDevPanel\Kernel\Collector\TranslatorCollectorCaptures translation lookups during request execution.final Kernel · class · implements SummaryCollectorInterface
SymfonyEventDispatcherProxyAppDevPanel\Adapter\Symfony\Proxy\SymfonyEventDispatcherProxyWraps Symfony's event dispatcher to intercept dispatched events.final Adapter/Symfony · class · implements EventDispatcherInterfaceSymfonyEventDispatcherInterfaceSymfony\Contracts\EventDispatcher\EventDispatcherInterfaceSymfony Event Dispatcher Contract. Dispatches events to registered listeners.Symfony · interfaceEventCollectorAppDevPanel\Kernel\Collector\EventCollectorCollects Event data during application lifecycle.final Kernel · class · implements SummaryCollectorInterface
LaravelTranslatorProxyAppDevPanel\Adapter\Laravel\Proxy\LaravelTranslatorProxyDecorates Laravel's Translator to feed translation lookups to TranslatorCollector.final Adapter/Laravel · class · implements TranslatorLaravelTranslatorIlluminate\Contracts\Translation\TranslatorLaravel Translator Contract. Provides translation services for the application.Laravel · interfaceTranslatorCollectorAppDevPanel\Kernel\Collector\TranslatorCollectorCaptures translation lookups during request execution.final Kernel · class · implements SummaryCollectorInterface
LaravelEventDispatcherProxyAppDevPanel\Adapter\Laravel\Proxy\LaravelEventDispatcherProxyWraps Laravel's event dispatcher to intercept dispatched events.final Adapter/Laravel · class · implements DispatcherLaravelDispatcherEventCollectorAppDevPanel\Kernel\Collector\EventCollectorCollects Event data during application lifecycle.final Kernel · class · implements SummaryCollectorInterface
TranslatorInterfaceProxyAppDevPanel\Adapter\Yii3\Collector\Translator\TranslatorInterfaceProxyDecorates Yiisoft TranslatorInterface to feed translation lookups to TranslatorCollector.final Adapter/Yii3 · class · implements TranslatorInterfaceYii 3TranslatorInterfaceTranslatorCollectorAppDevPanel\Kernel\Collector\TranslatorCollectorCaptures translation lookups during request execution.final Kernel · class · implements SummaryCollectorInterface
ValidatorInterfaceProxyAppDevPanel\Adapter\Yii3\Collector\Validator\ValidatorInterfaceProxyDecorator proxy for Validator Interface. Intercepts calls and forwards data to collectors.final Adapter/Yii3 · class · implements ValidatorInterfaceYii 3ValidatorInterfaceValidatorCollectorAppDevPanel\Kernel\Collector\ValidatorCollectorCaptures validation operations with results.final Kernel · class · implements SummaryCollectorInterface
ContainerInterfaceProxyAppDevPanel\Adapter\Yii3\Proxy\ContainerInterfaceProxyDecorator proxy for Container Interface. Intercepts calls and forwards data to collectors.final Adapter/Yii3 · class · implements ContainerInterfaceYii 3PSR-11 ContainerInterfacePsr\Container\ContainerInterfacePSR-11 Container Interface. Describes the interface of a dependency injection container.PSR-11 · interfaceServiceCollectorAppDevPanel\Kernel\Collector\ServiceCollectorCollects Service data during application lifecycle.final Kernel · class · implements SummaryCollectorInterface
I18NProxyAppDevPanel\Adapter\Yii2\Proxy\I18NProxyDecorates Yii 2's I18N component to feed translation lookups to TranslatorCollector.final Adapter/Yii2 · class · extends I18NYii 2yii\i18n\I18NTranslatorCollectorAppDevPanel\Kernel\Collector\TranslatorCollectorCaptures translation lookups during request execution.final Kernel · class · implements SummaryCollectorInterface

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.final Kernel · class · implements SummaryCollectorInterface. See the Translator page for full details.

Symfony -- decorates TranslatorInterfaceSymfony\Contracts\Translation\TranslatorInterfaceSymfony Translation Contract. Translates messages using message catalogs.Symfony · interface via setDecoratedService() in the compiler pass. Intercepts trans() calls.

Laravel -- decorates TranslatorIlluminate\Contracts\Translation\TranslatorLaravel Translator Contract. Provides translation services for the application.Laravel · interface 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.final Adapter/Yii3 · class · implements ValidatorInterface. 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:

php
// 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/

Released under the MIT License.