daylerees / container-debug
从 Artisan 检查 Laravel IoC 容器。
4.0.0
2013-10-08 19:58 UTC
Requires
- illuminate/console: 4.0.*
- illuminate/container: 4.0.*
Requires (Dev)
- mockery/mockery: 0.8.*
- phpunit/phpunit: 3.7.*
- symfony/event-dispatcher: 2.3.*
This package is not auto-updated.
Last update: 2024-09-10 04:06:10 UTC
README
容器调试
容器调试命令可用于检查 Laravel 四服务容器。它与 Symfony 框架中的 container:debug 类似。它将显示所有绑定、它们的类型、如果为标量则显示其值以及解析每个绑定所需的时间。
安装
将以下依赖项添加到您的 Laravel 项目中
"daylerees/container-debug": "4.0.*"
现在运行...
composer update
以下载软件包。现在将服务提供者添加到项目配置文件 app/config/app.php
中。
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
--- more ---
'DayleRees\ContainerDebug\ServiceProvider'
),
现在您可以使用 Artisan CLI 工具执行命令。
用法
php artisan container:debug
您将看到类似于以下输出的内容。
+--------------------------+------------------------------------------------------------+----------------------+
| Identifier | Service | Resolution time (ms) |
+--------------------------+------------------------------------------------------------+----------------------+
| artisan | Illuminate\Console\Application | 0.011 |
| asset.publisher | Illuminate\Foundation\AssetPublisher | 0.020 |
| auth | Illuminate\Auth\AuthManager | 0.023 |
| auth.reminder | Unable to resolve service. | N/A |
| auth.reminder.repository | Unable to resolve service. | N/A |
| cache | Illuminate\Cache\CacheManager | 0.044 |
| command.asset.publish | Illuminate\Foundation\Console\AssetPublishCommand | 0.058 |
| command.auth.reminders | Illuminate\Auth\Console\MakeRemindersCommand | 0.029 |
| command.cache.clear | Illuminate\Cache\Console\ClearCommand | 0.023 |
| command.dump-autoload | Illuminate\Foundation\Console\AutoloadCommand | 0.022 |
| command.environment | Illuminate\Foundation\Console\EnvironmentCommand | 0.023 |
| command.key.generate | Illuminate\Foundation\Console\KeyGenerateCommand | 0.022 |
| env | <string> "production" | 0.017 |
| events | Illuminate\Events\Dispatcher | 0.018 |
| exception | Illuminate\Exception\Handler | 0.019 |
| exception.debug | Illuminate\Exception\WhoopsDisplayer | 0.018 |
+--------------------------+------------------------------------------------------------+----------------------+
第一列包含 IoC 容器内服务的标识符。
第二列包含关于服务的信息,该信息取决于其类型
- (标量值)类型和值。例如 "foo"
- (非标量值)值的类型。例如
- (对象)对象的类名。例如 DateTime
如果解析服务时抛出异常,则该列将显示 '无法解析服务'。
第三列显示从 IoC 容器解析服务所需的时间(以毫秒为单位)。
可能的用途
- 快速查找容器对象:php artisan container:debug | grep "mail"
- 找出哪些类由 Facades 代表容器对象。
- 通过研究容器对象的解析时间来诊断性能问题。
享受使用,并且像往常一样,为仓库打星标,告诉你的朋友!