carlosekt/psql_debug 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Include packagist repository into your project.
composer require carlosekt/psql_debug

OR include file into your code

include 'path_to_class' . 'PSQL_Debug.php';
  1. In public/index.php after <?php open tag add:
     define('SYSTEM_START_TIME', microtime(true));
  1. Into your config add variable:
    ...
    'sql_debug' => true //false
    ...
  1. After echo $application->handle()->getContent(); add:
    if ($di->get('config')->sql_debug) {
        \CarlosEkt\PSQL_Debug::getInstance()->end(microtime(true));
    }
  1. 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);

##At the bottom of the page will appear: alt text

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固