phpexpertsinc/doctrine-detective
Composer 安装命令:
composer require phpexpertsinc/doctrine-detective
包简介
A Symfony2 Bundle that provides a detailed SQL query log for both HTML and JSON responses, including the SQL query, its location, and duration, organized by Controller -> Service -> Repository.
README 文档
README
Doctrine Detective is a Symfony2 Bundle that provides a detailed SQL query log for both HTML and JSON responses, including the SQL query, its location, and duration, organized by Controller -> Service -> Repository.
It is mainly useful for debugging, profiling and refactoring your Doctrine ORM queries into far more efficient Doctrine DBAL queries.
Unlike other SQL loggers, Doctrine Detective has the following features:
- Queries are organized hierarchically by class and method.
- Prepared statements have the parameters interpolated, so you can directly query them against the database.
- RESTful API support.
Installation
- Add
"phpexpertsinc/doctrine-detective" : "1.*"to your composer.json. - Run
$ composer update phpexpertsinc/doctrine-detective. - Edit
app/appKernel.php. - Add
new PHPExperts\DoctrineDetectiveBundle\DoctrineDetectiveBundle(),to theAppKernel::registerBundles()array. -or- (prefered), add it to just thedevandtestenvironments:
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new PHPExperts\DoctrineDetectiveBundle\DoctrineDetectiveBundle();
}
Output
HTML Response
At the end of every HTML response, you will find the following:
<div class="doctrineDetective-SQLLog">
<table>
<tr>
<td>TestController::getActiveUsersAction</td>
<td>3.886604999847429 ms</td>
<td>-</td>
</tr>
<tr>
<td>UserService</td>
<td>3.37965652160646 ms</td>
<td>-</td>
</tr>
<tr>
<td>UserService::getUsers(), Line 210</td>
<td>2.622127532959 ms</td>
<td>SELECT * FROM users WHERE ids IN (1, 2, 3, 4, 5)</td>
</tr>
<tr>
<td>UserRepository</td>
<td>0.75697898864746 ms</td>
<td>-</td>
</tr>
<tr>
<td>UserRepository::isActive(), Line 115</td>
<td>0.75697898864746</td>
<td>SELECT last_visit FROM login_log WHERE userId IN (1, 2, 3, 4, 5)</td>
</tr>
</table>
</div>
JSON Response
At the end of your JSON response, you will find the sqlLog array:
"sqlLog": {
"TestController::getActiveUsersAction": {
"time": 3.886604999847429,
"UserService": {
"time": 3.37965652160646,
"getUsers": {
"time": 2.622127532959,
"queries": [
{
"query": "SELECT * FROM users WHERE ids IN (1, 2, 3, 4, 5)",
"line": 210,
"time": 2.622127532959
}
]
},
},
"UserRepository": {
"isActive": {
"time": 0.75697898864746,
"queries": [
{
"query": "SELECT last_visit FROM login_log WHERE userId IN (1, 2, 3, 4, 5)",
"line": 115,
"time": 0.75697898864746
}
]
},
}
}
}
phpexpertsinc/doctrine-detective 适用场景与选型建议
phpexpertsinc/doctrine-detective 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.44k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2015 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 phpexpertsinc/doctrine-detective 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpexpertsinc/doctrine-detective 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 23.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-01