Skip to content

pastuhov/yii2-query-tag

Repository files navigation

Build Status Scrutinizer Code Quality Code Coverage Total Downloads

Query tag extension for Yii 2

Do you use pgbabger or pg_stat_statements ? And sometimes it can be difficult to understand which code generates the request? yii2-query-tag will help!

Before:

SELECT * FROM page WHERE 1=1

After:

SELECT /* ExampleTest:11 UnitHelper:28 Step:218 */ * FROM page WHERE 1=1

Features

  • Production ready/safe/tested
  • Saves team time

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist pastuhov/yii2-query-tag

or add

"require-dev": {
    "pastuhov/yii2-query-tag": "~1.1.0"
    ...

to the require section of your composer.json file.

Usage

Change your app config:

    'components' => [
        'db' => [
            'class' => \yii\db\Connection::class,
            'commandClass' => \pastuhov\querytag\Command::class, // <-- add this line

Advanced usage

Extend query tag command class:

namespace app\components;

class Command extends \pastuhov\querytag\Command
{
    public $customTag = 'master';
    public $enabledTags = [
        self::TAG_TYPE_CUSTOM,
        self::TAG_TYPE_TRACE,
    ];
}

Testing

./vendor/bin/codecept run

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.