carlosekt/psql_debug
Composer 安装命令:
composer require carlosekt/psql_debug
包简介
Phalcon SQL Debug Bar for version 3.x.x
README 文档
README
Phalcon SQL Debug Bar for version 3.x.x
Support Raw SQL, PHQL, replace phalcon placeholders
It shows queries, queries execution time, highlights long and erroneous queries, plus small system information ...
Installation
- Include packagist repository into your project.
composer require carlosekt/psql_debug
OR include file into your code
include 'path_to_class' . 'PSQL_Debug.php';
- In public/index.php after <?php open tag add:
define('SYSTEM_START_TIME', microtime(true));
- Into your config add variable:
... 'sql_debug' => true //false ...
- After echo $application->handle()->getContent(); add:
if ($di->get('config')->sql_debug) { \CarlosEkt\PSQL_Debug::getInstance()->end(microtime(true)); }
- In loadServices() function, where you set DB connection in DI add:
//Example register a 'db' service in the container $di->set('db', function () use ($config) { $connection = new \Phalcon\Db\Adapter\Pdo\Mysql([ 'host' => $config->database->host, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->dbname, 'charset' => $config->database->charset ]); if ($config->sql_debug) { $eventsManager = new \Phalcon\Events\Manager(); \CarlosEkt\PSQL_Debug::getInstance()->init(SYSTEM_START_TIME); $eventsManager->attach('db', function ($event) { /** @var Phalcon\Events\Event $event */ if ($event->getType() === 'beforeQuery') { \CarlosEkt\PSQL_Debug::getInstance()->queryStart(microtime(true)); } if ($event->getType() === 'afterQuery') { $sql = \CarlosEkt\PSQL_Debug::getInstance()->getLastQuery(true); \CarlosEkt\PSQL_Debug::getInstance()->queryEnd($sql, microtime(true)); } }); $connection->setEventsManager($eventsManager); } return $connection; }, true);
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-18