Skip to content

Yii 2 Adapter

The Yii 2 adapter bridges ADP Kernel and API into Yii 2.0.50+ via the bootstrap mechanism.

Installation

bash
composer require app-dev-panel/adapter-yii2

The package auto-registers via extra.bootstrap in composer.json. The BootstrapAppDevPanel\Adapter\Yii2\BootstrapYii 2 bootstrap component that registers the ADP debug module.final Adapter/Yii2 · class · implements BootstrapInterface class registers the debug-panel module automatically when YII_DEBUG is enabled.

Configuration

Configure the module in your application config:

php
'modules' => [
    'debug-panel' => [
        'class' => \AppDevPanel\Adapter\Yii2\Module::class,
        'storagePath' => '@runtime/debug',
        'historySize' => 50,
        'collectors' => [
            'request' => true,
            'exception' => true,
            'log' => true,
            'event' => true,
            'db' => true,
            'mailer' => true,
            'assets' => true,
            'redis' => true,
            'elasticsearch' => true,
            'template' => true,
            'code_coverage' => false, // opt-in, requires pcov or xdebug
            // ... all collectors enabled by default
        ],
        'ignoredRequests' => ['/debug/api/**', '/inspect/api/**'],
        'ignoredCommands' => ['help', 'list', 'cache/*', 'asset/*'],
        'allowedIps' => ['127.0.0.1', '::1'],
    ],
],

Collectors

Supports all Kernel collectors plus Yii 2-specific data capture:

CollectorMechanismData
DatabaseDbProfilingTarget (Yii logger)SQL queries, timing, row count
LogDebugLogTargetAppDevPanel\Adapter\Yii2\Collector\DebugLogTargetReal-time log target that feeds Yii 2 log messages to ADP's LogCollector.final Adapter/Yii2 · class · extends Target (real-time Yii log target)Log messages with PSR-3 level mapping
MailerBaseMailer::EVENT_AFTER_SENDFrom, to, cc, bcc, subject, body
Asset BundlesView::EVENT_END_PAGEBundles: class, paths, CSS/JS, dependencies
TranslatorI18NProxyAppDevPanel\Adapter\Yii2\Proxy\I18NProxyDecorates Yii 2's I18N component to feed translation lookups to TranslatorCollector.final Adapter/Yii2 · class · extends I18N replaces Yii::$app->i18nTranslation lookups, missing translations
TemplateView::EVENT_BEFORE_RENDER + EVENT_AFTER_RENDERRender timing, output, parameters (supports nesting)
RedisDirect collector callsRedis commands, timing, errors
ElasticsearchDirect collector callsES requests, timing, hits
Code Coveragepcov / xdebug extensionPer-file line coverage (opt-in)
AuthorizationUser::EVENT_AFTER_LOGIN/LOGOUTAuth events, user identity
RouterUrlRuleProxyAppDevPanel\Adapter\Yii2\Proxy\UrlRuleProxyWraps a Yii 2 URL rule to intercept successful route matching.final Adapter/Yii2 · class · implements UrlRuleInterface wraps all URL rulesRoute matching data, timing

Template Collector

The TemplateCollector hooks into View::EVENT_BEFORE_RENDER and EVENT_AFTER_RENDER to capture every view rendering with its file path, output, parameters, and timing. Handles nested view rendering correctly (e.g., layout → partial → widget) using a per-file timer stack. Detects duplicate renders automatically.

Code Coverage

Code coverage is opt-in ('code_coverage' => false by default). Requires the pcov or xdebug PHP extension. Without either, the collector returns driver: null. See Collectors — Code Coverage for details.

Translator Integration

The adapter replaces Yii 2's i18n application component with I18NProxyAppDevPanel\Adapter\Yii2\Proxy\I18NProxyDecorates Yii 2's I18N component to feed translation lookups to TranslatorCollector.final Adapter/Yii2 · class · extends I18N — an extended yii\i18n\I18N that overrides translate(). All Yii::t() calls are intercepted and logged to TranslatorCollectorAppDevPanel\Kernel\Collector\TranslatorCollectorCaptures translation lookups during request execution.final Kernel · class · implements SummaryCollectorInterface automatically. See Translator for details.

Database Inspector

Yii2DbSchemaProvider provides database schema inspection via yii\db\Schema. Falls back to NullSchemaProviderAppDevPanel\Adapter\Yii2\Inspector\NullSchemaProviderNo-op schema provider for when no database is configured. Returns empty results instead of causing a 500 error.final Adapter/Yii2 · class · implements SchemaProviderInterface when no database component is configured.

Released under the MIT License.