Yii 2 Adapter
The Yii 2 adapter bridges ADP Kernel and API into Yii 2.0.50+ via the bootstrap mechanism.
Installation
composer require app-dev-panel/adapter-yii2The package auto-registers via extra.bootstrap in composer.json. The BootstrapAppDevPanel\Adapter\Yii2\BootstrapYii 2 bootstrap component that registers the ADP debug module. class registers the debug-panel module automatically when YII_DEBUG is enabled.
Configuration
Configure the module in your application config:
'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:
| Collector | Mechanism | Data |
|---|---|---|
| Database | DbProfilingTarget (Yii logger) | SQL queries, timing, row count |
| Log | DebugLogTargetAppDevPanel\Adapter\Yii2\Collector\DebugLogTargetReal-time log target that feeds Yii 2 log messages to ADP's LogCollector. (real-time Yii log target) | Log messages with PSR-3 level mapping |
| Mailer | BaseMailer::EVENT_AFTER_SEND | From, to, cc, bcc, subject, body |
| Asset Bundles | View::EVENT_END_PAGE | Bundles: class, paths, CSS/JS, dependencies |
| Translator | I18NProxyAppDevPanel\Adapter\Yii2\Proxy\I18NProxyDecorates Yii 2's I18N component to feed translation lookups to TranslatorCollector. replaces Yii::$app->i18n | Translation lookups, missing translations |
| Template | View::EVENT_BEFORE_RENDER + EVENT_AFTER_RENDER | Render timing, output, parameters (supports nesting) |
| Redis | Direct collector calls | Redis commands, timing, errors |
| Elasticsearch | Direct collector calls | ES requests, timing, hits |
| Code Coverage | pcov / xdebug extension | Per-file line coverage (opt-in) |
| Authorization | User::EVENT_AFTER_LOGIN/LOGOUT | Auth events, user identity |
| Router | UrlRuleProxyAppDevPanel\Adapter\Yii2\Proxy\UrlRuleProxyWraps a Yii 2 URL rule to intercept successful route matching. wraps all URL rules | Route 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. — 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. 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. when no database component is configured.