master 29ec5739a081 cached
29 files
22.0 KB
6.5k tokens
36 symbols
1 requests
Download .txt
Repository: dmitry-ivanov/laravel-db-profiler
Branch: master
Commit: 29ec5739a081
Files: 29
Total size: 22.0 KB

Directory structure:
gitextract__81p91l1/

├── .editorconfig
├── .gitattributes
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── 1_Bug_Report.md
│   │   ├── 2_Feature_Request.md
│   │   └── 3_Laravel_Version_Support.md
│   ├── PULL_REQUEST_TEMPLATE.md
│   └── workflows/
│       └── tests.yml
├── .gitignore
├── LICENSE.md
├── README.md
├── art/
│   ├── sponsor-laravel-idea.pxd/
│   │   ├── QuickLook/
│   │   │   ├── Icon.tiff
│   │   │   └── Thumbnail.tiff
│   │   ├── data/
│   │   │   └── originalImportedContentDocumentInfo
│   │   └── metadata.info
│   └── sponsor-material-theme.pxd/
│       ├── QuickLook/
│       │   ├── Icon.tiff
│       │   └── Thumbnail.tiff
│       ├── data/
│       │   ├── 0D6D801E-30F3-46BF-815B-DC27D2EB5BE0
│       │   └── originalImportedContentDocumentInfo
│       └── metadata.info
├── composer.json
├── config/
│   └── db-profiler.php
├── phpunit.xml.dist
├── src/
│   ├── DbProfilerDumper.php
│   └── DbProfilerServiceProvider.php
└── tests/
    ├── ConsoleProfilingTest.php
    ├── HttpProfilingTest.php
    ├── TestCase.php
    └── fixture/
        ├── app/
        │   └── Post.php
        └── database/
            └── migrations/
                └── 2016_11_01_131415_create_posts_table.php

================================================
FILE CONTENTS
================================================

================================================
FILE: .editorconfig
================================================
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2


================================================
FILE: .gitattributes
================================================
* text=auto

/.github            export-ignore
/doc                export-ignore
/tests              export-ignore
.editorconfig       export-ignore
.gitattributes      export-ignore
.gitignore          export-ignore
phpunit.xml.dist    export-ignore


================================================
FILE: .github/ISSUE_TEMPLATE/1_Bug_Report.md
================================================
---
name: "🐞 Bug Report"
about: 'If you want to report an issue.'
---

### Versions:

- Package Version: #.#.#
- PHP Version: #.#.#

### Description:

...

### Steps to reproduce:

...

#### Expected:

...

#### Actual:

...


================================================
FILE: .github/ISSUE_TEMPLATE/2_Feature_Request.md
================================================
---
name: "💡 Feature Request"
about: 'If you want to propose an idea.'
---

### Description:

...


================================================
FILE: .github/ISSUE_TEMPLATE/3_Laravel_Version_Support.md
================================================
---
name: "🛠 Laravel Version Support"
about: 'If you want to support a new Laravel version.'
---

<!-- Here's how to support a new Laravel version. Thanks for your help! 👍 -->

### Follow these steps:

> Please, note that we have to update versions for everything, not only `illuminate` packages.

1. Update versions in `composer.json` according to Laravel's `composer.json`.
2. Add the newly supported version to `README.md`.
3. Open PR to the `master` branch.


================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
<!--
Please, provide a descriptive title, thorough description, and tests for your PR.

Also, make sure that all CI checks have passed: Code Style, Tests, Tests Coverage, etc.
-->


================================================
FILE: .github/workflows/tests.yml
================================================
name: tests

on: [push, pull_request]

jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php: [8.2, 8.3, 8.4]
        stability: [prefer-lowest, prefer-stable]

    name: PHP ${{ matrix.php }} / ${{ matrix.stability }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: sqlite3
          tools: composer:v2
          coverage: xdebug

      - name: Setup problem matchers
        run: |
          echo "::add-matcher::${{ runner.tool_cache }}/php.json"
          echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: Install dependencies
        uses: nick-invision/retry@v2
        with:
          timeout_minutes: 5
          max_attempts: 5
          command: composer update --prefer-dist --${{ matrix.stability }} --no-interaction --no-progress --ansi

      - name: Run tests
        run: vendor/bin/phpunit --colors=always --coverage-clover ./build/logs/clover.xml

      - name: Code coverage
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./build/logs/clover.xml
          fail_ci_if_error: true


================================================
FILE: .gitignore
================================================
/.idea
/.phpunit.cache
/.vscode
/vendor
.DS_Store
.phpunit.result.cache
Thumbs.db
composer.lock
composer.phar
phpunit.xml


================================================
FILE: LICENSE.md
================================================
The MIT License (MIT)

Copyright (c) Dmitry Ivanov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


================================================
FILE: README.md
================================================
![Database Profiler for Laravel Web and Console Applications](art/1380x575-optimized.jpg)

# Laravel Database Profiler

[<img src="https://user-images.githubusercontent.com/1286821/181085373-12eee197-187a-4438-90fe-571ac6d68900.png" alt="Buy me a coffee" width="200" />](https://buymeacoffee.com/dmitry.ivanov)

[![StyleCI](https://github.styleci.io/repos/68023936/shield?branch=master&style=flat)](https://github.styleci.io/repos/68023936?branch=master)
[![Build Status](https://img.shields.io/github/actions/workflow/status/dmitry-ivanov/laravel-db-profiler/tests.yml?branch=master)](https://github.com/dmitry-ivanov/laravel-db-profiler/actions?query=workflow%3Atests+branch%3Amaster)
[![Coverage Status](https://img.shields.io/codecov/c/github/dmitry-ivanov/laravel-db-profiler/master)](https://app.codecov.io/gh/dmitry-ivanov/laravel-db-profiler/tree/master)

![Packagist Version](https://img.shields.io/packagist/v/illuminated/db-profiler)
![Packagist Stars](https://img.shields.io/packagist/stars/illuminated/db-profiler)
![Packagist Downloads](https://img.shields.io/packagist/dt/illuminated/db-profiler)
![Packagist License](https://img.shields.io/packagist/l/illuminated/db-profiler)

Database Profiler for Laravel Web and Console Applications.

> A simple tool that works correctly even with `dd()` in your code.

| Laravel | Database Profiler                                                      |
|---------|------------------------------------------------------------------------|
| 12.x    | [12.x](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/12.x) |
| 11.x    | [11.x](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/11.x) |
| 10.x    | [10.x](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/10.x) |
| 9.x     | [9.x](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/9.x)   |
| 8.x     | [8.x](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/8.x)   |
| 7.x     | [7.x](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/7.x)   |
| 6.x     | [6.x](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/6.x)   |
| 5.8.*   | [5.8.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.8) |
| 5.7.*   | [5.7.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.7) |
| 5.6.*   | [5.6.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.6) |
| 5.5.*   | [5.5.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.5) |
| 5.4.*   | [5.4.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.4) |
| 5.3.*   | [5.3.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.3) |
| 5.2.*   | [5.2.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.2) |
| 5.1.*   | [5.1.*](https://github.com/dmitry-ivanov/laravel-db-profiler/tree/5.1) |

## Usage

1. Install the package via Composer:

    ```shell script
    composer require illuminated/db-profiler
    ```

2. Use the `vvv` parameter for Web:

    ![Laravel Database Profiler - Demo - Web](doc/img/demo-web-c.gif)

3. Use the `-vvv` option for Console:

    ![Laravel Database Profiler - Demo - Console](doc/img/demo-console.gif)

## Local by default

Enabled only for the `local` environment, so you don't have to worry about `production`.

If you want to force profiling for non-local environments - specify it explicitly in your `.env` file:

> DB_PROFILER_FORCE=true

## Sponsors

[![Laravel Idea](art/sponsor-laravel-idea.png)](https://laravel-idea.com)<br>
[![Material Theme UI Plugin](art/sponsor-material-theme.png)](https://material-theme.com)<br>

## License

Laravel Database Profiler is open-sourced software licensed under the [MIT license](LICENSE.md).

[<img src="https://user-images.githubusercontent.com/1286821/181085373-12eee197-187a-4438-90fe-571ac6d68900.png" alt="Buy me a coffee" width="200" />](https://buymeacoffee.com/dmitry.ivanov)&nbsp;


================================================
FILE: composer.json
================================================
{
    "name": "illuminated/db-profiler",
    "description": "Database Profiler for Laravel Web and Console Applications.",
    "keywords": ["laravel", "db", "database", "profiler", "profiling", "query", "sql", "mysql", "web-profiling", "console-profiling"],
    "license": "MIT",
    "support": {
        "issues": "https://github.com/dmitry-ivanov/laravel-db-profiler/issues",
        "source": "https://github.com/dmitry-ivanov/laravel-db-profiler"
    },
    "authors": [{
        "name": "Dmitry Ivanov",
        "email": "dmitry.g.ivanov@gmail.com"
    }],
    "require": {
        "php": "^8.2",
        "illuminate/database": "^12.0",
        "illuminate/support": "^12.0"
    },
    "require-dev": {
        "phpunit/phpunit": "^11.5.3",
        "mockery/mockery": "^1.6.10",
        "orchestra/testbench": "^10.0",
        "illuminated/testing-tools": "^12.0",
        "illuminated/helper-functions": "^12.0"
    },
    "autoload": {
        "psr-4": {
            "Illuminated\\Database\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Illuminated\\Database\\Tests\\": "tests/",
            "Illuminated\\Database\\Tests\\App\\": "tests/fixture/app/"
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "Illuminated\\Database\\DbProfilerServiceProvider"
            ]
        }
    },
    "config": {
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}


================================================
FILE: config/db-profiler.php
================================================
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Force Profiling
    |--------------------------------------------------------------------------
    |
    | If you want to enable profiling for non-local environments,
    | you should set this config variable to the `true` value,
    | by using the `DB_PROFILER_FORCE` in your `.env` file.
    |
    */

    'force' => env('DB_PROFILER_FORCE', false),

];


================================================
FILE: phpunit.xml.dist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
    beStrictAboutTestsThatDoNotTestAnything="false"
    beStrictAboutOutputDuringTests="true"
    bootstrap="vendor/autoload.php"
    colors="true"
    displayDetailsOnPhpunitDeprecations="true"
    displayDetailsOnTestsThatTriggerErrors="true"
    displayDetailsOnTestsThatTriggerNotices="true"
    displayDetailsOnTestsThatTriggerWarnings="true"
>
    <testsuites>
        <testsuite name="Laravel DB Profiler Test Suite">
            <directory>./tests</directory>
        </testsuite>
    </testsuites>

    <source>
        <include>
            <directory>./src</directory>
        </include>

        <exclude>
            <file>./src/DbProfilerDumper.php</file>
        </exclude>
    </source>
</phpunit>


================================================
FILE: src/DbProfilerDumper.php
================================================
<?php

namespace Illuminated\Database;

class DbProfilerDumper
{
    /**
     * Dump the given query.
     */
    public function dump(string $query): void
    {
        /** @noinspection ForgottenDebugOutputInspection */
        dump($query);
    }
}


================================================
FILE: src/DbProfilerServiceProvider.php
================================================
<?php

namespace Illuminated\Database;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;

class DbProfilerServiceProvider extends ServiceProvider
{
    /**
     * The query counter.
     */
    private int $counter = 1;

    /**
     * Register the service provider.
     */
    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__.'/../config/db-profiler.php', 'db-profiler');

        app()->instance('db.idpdumper', new DbProfilerDumper());
    }

    /**
     * Boot the service provider.
     */
    public function boot(): void
    {
        if (!$this->isEnabled()) {
            return;
        }

        DB::listen(function (QueryExecuted $query) {
            $i = $this->counter++;
            $sql = $this->applyQueryBindings($query->sql, $query->bindings);
            $time = $query->time;
            app('db.idpdumper')->dump("[{$i}]: {$sql}; ({$time} ms)");
        });
    }

    /**
     * Check whether database profiling is enabled or not.
     */
    private function isEnabled(): bool
    {
        if (!$this->app->isLocal() && !config('db-profiler.force')) {
            return false;
        }

        return $this->app->runningInConsole()
            ? collect($_SERVER['argv'])->contains('-vvv')
            : Request::exists('vvv');
    }

    /**
     * Apply query bindings to the given SQL query.
     */
    private function applyQueryBindings(string $sql, array $bindings): string
    {
        $bindings = collect($bindings)->map(function ($binding) {
            return match (gettype($binding)) {
                'boolean' => (int) $binding,
                'string' => "'{$binding}'",
                default => $binding,
            };
        })->toArray();

        return Str::replaceArray('?', $bindings, $sql);
    }
}


================================================
FILE: tests/ConsoleProfilingTest.php
================================================
<?php

namespace Illuminated\Database\Tests;

use PHPUnit\Framework\Attributes\Test;

class ConsoleProfilingTest extends TestCase
{
    /**
     * Define whether the app is running in console or not.
     */
    protected function runningInConsole(): bool
    {
        return true;
    }

    /**
     * Emulate the "vvv" flag set.
     */
    protected function withVvv(): self
    {
        $_SERVER['argv']['-vvv'] = true;

        return $this;
    }

    #[Test]
    public function it_is_disabled_if_environment_is_not_local(): void
    {
        $this->notLocal()->boot();

        $this->assertDbProfilerNotActivated();
    }

    #[Test]
    public function it_is_disabled_if_environment_is_local_but_there_is_no_vvv_option(): void
    {
        $this->local()->boot();

        $this->assertDbProfilerNotActivated();
    }

    #[Test]
    public function it_is_enabled_if_environment_is_local_and_there_is_vvv_option(): void
    {
        $this->local()->withVvv()->boot();

        $this->assertDbProfilerActivated();
        $this->assertDbQueriesDumped();
    }

    #[Test]
    public function it_is_enabled_if_environment_is_not_local_but_there_is_a_force_flag_in_config(): void
    {
        config(['db-profiler.force' => true]);

        $this->notLocal()->withVvv()->boot();

        $this->assertDbProfilerActivated();
        $this->assertDbQueriesDumped();
    }
}


================================================
FILE: tests/HttpProfilingTest.php
================================================
<?php

namespace Illuminated\Database\Tests;

use Illuminate\Support\Facades\Request;
use PHPUnit\Framework\Attributes\Test;

class HttpProfilingTest extends TestCase
{
    /**
     * Define whether the app is running in console or not.
     */
    protected function runningInConsole(): bool
    {
        return false;
    }

    /**
     * Emulate the "vvv" flag set.
     */
    protected function withVvv(): self
    {
        Request::merge(['vvv' => true]);

        return $this;
    }

    #[Test]
    public function it_is_disabled_if_environment_is_not_local(): void
    {
        $this->notLocal()->boot();

        $this->assertDbProfilerNotActivated();
    }

    #[Test]
    public function it_is_disabled_if_environment_is_local_but_there_is_no_vvv_request_param(): void
    {
        $this->local()->boot();

        $this->assertDbProfilerNotActivated();
    }

    #[Test]
    public function it_is_enabled_if_environment_is_local_and_there_is_vvv_request_param(): void
    {
        $this->local()->withVvv()->boot();

        $this->assertDbProfilerActivated();
        $this->assertDbQueriesDumped();
    }
}


================================================
FILE: tests/TestCase.php
================================================
<?php

namespace Illuminated\Database\Tests;

use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\DB;
use Illuminated\Database\DbProfilerServiceProvider;
use Illuminated\Database\Tests\App\Post;
use Illuminated\Testing\TestingTools;
use Mockery;

Mockery::globalHelpers();

abstract class TestCase extends \Orchestra\Testbench\TestCase
{
    use TestingTools;

    /**
     * The emulated environment.
     */
    private string $env;

    /**
     * Setup the test environment.
     */
    protected function setUp(): void
    {
        parent::setUp();

        $this->setUpDatabase();
    }

    /**
     * Setup the database.
     */
    private function setUpDatabase(): void
    {
        config(['database.default' => 'testing']);
        config(['database.connections.testing.foreign_key_constraints' => true]);

        $this->artisan('migrate', [
            '--database' => 'testing',
            '--path' => relative_path(__DIR__, base_path()) . '/fixture/database/migrations/',
        ])->assertSuccessful();
    }

    /**
     * Emulate the local environment.
     */
    protected function local(): self
    {
        $this->env = 'local';

        return $this;
    }

    /**
     * Emulate the non-local environment.
     */
    protected function notLocal(): self
    {
        $this->env = 'production';

        return $this;
    }

    /**
     * Define whether the app is running in console or not.
     */
    abstract protected function runningInConsole(): bool;

    /**
     * Emulate the "vvv" flag set.
     */
    abstract protected function withVvv(): self;

    /**
     * Emulate the app boot.
     */
    protected function boot(): void
    {
        $app = mock(Application::class);
        $app->expects('isLocal')->andReturn($this->env == 'local');
        $app->allows('runningInConsole')->andReturn($this->runningInConsole());
        $app->allows('configurationIsCached')->andReturnTrue();

        $serviceProvider = new DbProfilerServiceProvider($app);
        $serviceProvider->register();
        $serviceProvider->boot();
    }

    /**
     * Assert that the database profiler is activated.
     */
    protected function assertDbProfilerActivated(): void
    {
        $connection = DB::connection();
        $dispatcher = $connection->getEventDispatcher();
        $this->assertTrue($dispatcher->hasListeners(QueryExecuted::class));
    }

    /**
     * Assert that the database profiler is not activated.
     */
    protected function assertDbProfilerNotActivated(): void
    {
        $connection = DB::connection();
        $dispatcher = $connection->getEventDispatcher();
        $this->assertFalse($dispatcher->hasListeners(QueryExecuted::class));
    }

    /**
     * Assert that the database queries are dumped.
     */
    protected function assertDbQueriesDumped(): void
    {
        $queries = collect([
            '[1]: select * from "posts"',
            '[2]: select * from "posts" where "posts"."id" = 1 limit 1',
            '[3]: select * from "posts" where "posts"."id" = \'2\' limit 1',
            '[4]: select * from "posts" where "title" = \'foo bar baz\'',
            '[5]: select * from "posts" where "price" > 123.45',
            '[6]: select * from "posts" where "price" < \'543.21\'',
            '[7]: select * from "posts" where "is_enabled" = 1',
            '[8]: select * from "posts" where "is_enabled" = 0',
            '[9]: select * from "posts" where "is_enabled" = 1',
            '[10]: select * from "posts" where "is_enabled" = \'1\'',
            '[11]: select * from "posts" where "id" in (1, \'2\', 3)',
            '[12]: select * from "posts" where "title" in (\'foo\', \'bar\', \'baz\')',
            '[13]: select * from "posts" where "price" in (1.23, \'2.34\', 3.45)',
            '[14]: select * from "posts" where "is_enabled" in (1, 0, 1, 0, \'1\', \'0\')',
            '[15]: select * from "posts" where "id" > 3 and "title" = \'foo bar baz\' and "price" > 123.45 and "is_enabled" = 1 and "created_at" > \'2016-11-03 21:00:00\' limit 1',
            '[16]: select * from "posts" where "title" is null',
            '[17]: select * from "posts" where "title" is null and "price" > 123.45',
        ]);

        $mock = Mockery::mock();
        app()->instance('db.idpdumper', $mock);

        $queries->each(function (string $query) use ($mock) {
            $queryPattern = $this->prepareQueryPattern($query);
            $mock->shouldReceive('dump')->with(Mockery::pattern($queryPattern))->once();
        });

        Post::all();
        Post::query()->find(1);
        Post::query()->find('2');
        Post::query()->where('title', 'foo bar baz')->get();
        Post::query()->where('price', '>', 123.45)->get();
        Post::query()->where('price', '<', '543.21')->get();
        Post::query()->where('is_enabled', true)->get();
        Post::query()->where('is_enabled', false)->get();
        Post::query()->where('is_enabled', 1)->get();
        Post::query()->where('is_enabled', '1')->get();
        Post::query()->whereIn('id', [1, '2', 3])->get();
        Post::query()->whereIn('title', ['foo', 'bar', 'baz'])->get();
        Post::query()->whereIn('price', [1.23, '2.34', 3.45])->get();
        Post::query()->whereIn('is_enabled', [true, false, 1, 0, '1', '0'])->get();
        Post::query()->where('id', '>', 3)->where('title', 'foo bar baz')->where('price', '>', 123.45)->where('is_enabled', true)->where('created_at', '>', '2016-11-03 21:00:00')->first();
        Post::query()->where('title', null)->get();
        Post::query()->where('title', null)->where('price', '>', 123.45)->get();
    }

    /**
     * Prepare the query pattern for mocking.
     */
    private function prepareQueryPattern(string $query): string
    {
        $query = preg_quote($query, '/');

        return "/{$query}; \(.*? ms\)/";
    }

    /**
     * Clean up the testing environment before the next test.
     */
    protected function tearDown(): void
    {
        $connection = DB::connection();
        $dispatcher = $connection->getEventDispatcher();

        if ($dispatcher->hasListeners(QueryExecuted::class)) {
            $dispatcher->forget(QueryExecuted::class);
        }

        parent::tearDown();
    }
}


================================================
FILE: tests/fixture/app/Post.php
================================================
<?php

namespace Illuminated\Database\Tests\App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = ['title'];
}


================================================
FILE: tests/fixture/database/migrations/2016_11_01_131415_create_posts_table.php
================================================
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migration.
     */
    public function up(): void
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->float('price');
            $table->boolean('is_enabled');
            $table->timestamps();
        });
    }

    /**
     * Rollback the migration.
     */
    public function down(): void
    {
        Schema::drop('posts');
    }
};
Download .txt
gitextract__81p91l1/

├── .editorconfig
├── .gitattributes
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── 1_Bug_Report.md
│   │   ├── 2_Feature_Request.md
│   │   └── 3_Laravel_Version_Support.md
│   ├── PULL_REQUEST_TEMPLATE.md
│   └── workflows/
│       └── tests.yml
├── .gitignore
├── LICENSE.md
├── README.md
├── art/
│   ├── sponsor-laravel-idea.pxd/
│   │   ├── QuickLook/
│   │   │   ├── Icon.tiff
│   │   │   └── Thumbnail.tiff
│   │   ├── data/
│   │   │   └── originalImportedContentDocumentInfo
│   │   └── metadata.info
│   └── sponsor-material-theme.pxd/
│       ├── QuickLook/
│       │   ├── Icon.tiff
│       │   └── Thumbnail.tiff
│       ├── data/
│       │   ├── 0D6D801E-30F3-46BF-815B-DC27D2EB5BE0
│       │   └── originalImportedContentDocumentInfo
│       └── metadata.info
├── composer.json
├── config/
│   └── db-profiler.php
├── phpunit.xml.dist
├── src/
│   ├── DbProfilerDumper.php
│   └── DbProfilerServiceProvider.php
└── tests/
    ├── ConsoleProfilingTest.php
    ├── HttpProfilingTest.php
    ├── TestCase.php
    └── fixture/
        ├── app/
        │   └── Post.php
        └── database/
            └── migrations/
                └── 2016_11_01_131415_create_posts_table.php
Download .txt
SYMBOL INDEX (36 symbols across 7 files)

FILE: src/DbProfilerDumper.php
  class DbProfilerDumper (line 5) | class DbProfilerDumper
    method dump (line 10) | public function dump(string $query): void

FILE: src/DbProfilerServiceProvider.php
  class DbProfilerServiceProvider (line 11) | class DbProfilerServiceProvider extends ServiceProvider
    method register (line 21) | public function register(): void
    method boot (line 31) | public function boot(): void
    method isEnabled (line 48) | private function isEnabled(): bool
    method applyQueryBindings (line 62) | private function applyQueryBindings(string $sql, array $bindings): string

FILE: tests/ConsoleProfilingTest.php
  class ConsoleProfilingTest (line 7) | class ConsoleProfilingTest extends TestCase
    method runningInConsole (line 12) | protected function runningInConsole(): bool
    method withVvv (line 20) | protected function withVvv(): self
    method it_is_disabled_if_environment_is_not_local (line 27) | #[Test]
    method it_is_disabled_if_environment_is_local_but_there_is_no_vvv_option (line 35) | #[Test]
    method it_is_enabled_if_environment_is_local_and_there_is_vvv_option (line 43) | #[Test]
    method it_is_enabled_if_environment_is_not_local_but_there_is_a_force_flag_in_config (line 52) | #[Test]

FILE: tests/HttpProfilingTest.php
  class HttpProfilingTest (line 8) | class HttpProfilingTest extends TestCase
    method runningInConsole (line 13) | protected function runningInConsole(): bool
    method withVvv (line 21) | protected function withVvv(): self
    method it_is_disabled_if_environment_is_not_local (line 28) | #[Test]
    method it_is_disabled_if_environment_is_local_but_there_is_no_vvv_request_param (line 36) | #[Test]
    method it_is_enabled_if_environment_is_local_and_there_is_vvv_request_param (line 44) | #[Test]

FILE: tests/TestCase.php
  class TestCase (line 15) | abstract class TestCase extends \Orchestra\Testbench\TestCase
    method setUp (line 27) | protected function setUp(): void
    method setUpDatabase (line 37) | private function setUpDatabase(): void
    method local (line 51) | protected function local(): self
    method notLocal (line 61) | protected function notLocal(): self
    method runningInConsole (line 71) | abstract protected function runningInConsole(): bool;
    method withVvv (line 76) | abstract protected function withVvv(): self;
    method boot (line 81) | protected function boot(): void
    method assertDbProfilerActivated (line 96) | protected function assertDbProfilerActivated(): void
    method assertDbProfilerNotActivated (line 106) | protected function assertDbProfilerNotActivated(): void
    method assertDbQueriesDumped (line 116) | protected function assertDbQueriesDumped(): void
    method prepareQueryPattern (line 168) | private function prepareQueryPattern(string $query): string
    method tearDown (line 178) | protected function tearDown(): void

FILE: tests/fixture/app/Post.php
  class Post (line 7) | class Post extends Model

FILE: tests/fixture/database/migrations/2016_11_01_131415_create_posts_table.php
  method up (line 12) | public function up(): void
  method down (line 26) | public function down(): void
Condensed preview — 29 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (25K chars).
[
  {
    "path": ".editorconfig",
    "chars": 213,
    "preview": "root = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\nindent_style = space\nindent_size = 4\ntrim_"
  },
  {
    "path": ".gitattributes",
    "chars": 251,
    "preview": "* text=auto\n\n/.github            export-ignore\n/doc                export-ignore\n/tests              export-ignore\n.edit"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/1_Bug_Report.md",
    "chars": 225,
    "preview": "---\nname: \"🐞 Bug Report\"\nabout: 'If you want to report an issue.'\n---\n\n### Versions:\n\n- Package Version: #.#.#\n- PHP Ver"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/2_Feature_Request.md",
    "chars": 98,
    "preview": "---\nname: \"💡 Feature Request\"\nabout: 'If you want to propose an idea.'\n---\n\n### Description:\n\n...\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/3_Laravel_Version_Support.md",
    "chars": 462,
    "preview": "---\nname: \"🛠 Laravel Version Support\"\nabout: 'If you want to support a new Laravel version.'\n---\n\n<!-- Here's how to sup"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "chars": 180,
    "preview": "<!--\nPlease, provide a descriptive title, thorough description, and tests for your PR.\n\nAlso, make sure that all CI chec"
  },
  {
    "path": ".github/workflows/tests.yml",
    "chars": 1312,
    "preview": "name: tests\n\non: [push, pull_request]\n\njobs:\n  tests:\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n  "
  },
  {
    "path": ".gitignore",
    "chars": 122,
    "preview": "/.idea\n/.phpunit.cache\n/.vscode\n/vendor\n.DS_Store\n.phpunit.result.cache\nThumbs.db\ncomposer.lock\ncomposer.phar\nphpunit.xm"
  },
  {
    "path": "LICENSE.md",
    "chars": 1075,
    "preview": "The MIT License (MIT)\n\nCopyright (c) Dmitry Ivanov\n\nPermission is hereby granted, free of charge, to any person obtainin"
  },
  {
    "path": "README.md",
    "chars": 3850,
    "preview": "![Database Profiler for Laravel Web and Console Applications](art/1380x575-optimized.jpg)\n\n# Laravel Database Profiler\n\n"
  },
  {
    "path": "composer.json",
    "chars": 1485,
    "preview": "{\n    \"name\": \"illuminated/db-profiler\",\n    \"description\": \"Database Profiler for Laravel Web and Console Applications."
  },
  {
    "path": "config/db-profiler.php",
    "chars": 467,
    "preview": "<?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Force Prof"
  },
  {
    "path": "phpunit.xml.dist",
    "chars": 891,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSch"
  },
  {
    "path": "src/DbProfilerDumper.php",
    "chars": 252,
    "preview": "<?php\n\nnamespace Illuminated\\Database;\n\nclass DbProfilerDumper\n{\n    /**\n     * Dump the given query.\n     */\n    public"
  },
  {
    "path": "src/DbProfilerServiceProvider.php",
    "chars": 1930,
    "preview": "<?php\n\nnamespace Illuminated\\Database;\n\nuse Illuminate\\Database\\Events\\QueryExecuted;\nuse Illuminate\\Support\\Facades\\DB;"
  },
  {
    "path": "tests/ConsoleProfilingTest.php",
    "chars": 1389,
    "preview": "<?php\n\nnamespace Illuminated\\Database\\Tests;\n\nuse PHPUnit\\Framework\\Attributes\\Test;\n\nclass ConsoleProfilingTest extends"
  },
  {
    "path": "tests/HttpProfilingTest.php",
    "chars": 1131,
    "preview": "<?php\n\nnamespace Illuminated\\Database\\Tests;\n\nuse Illuminate\\Support\\Facades\\Request;\nuse PHPUnit\\Framework\\Attributes\\T"
  },
  {
    "path": "tests/TestCase.php",
    "chars": 6301,
    "preview": "<?php\n\nnamespace Illuminated\\Database\\Tests;\n\nuse Illuminate\\Database\\Events\\QueryExecuted;\nuse Illuminate\\Foundation\\Ap"
  },
  {
    "path": "tests/fixture/app/Post.php",
    "chars": 221,
    "preview": "<?php\n\nnamespace Illuminated\\Database\\Tests\\App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Post extends Model\n{\n  "
  },
  {
    "path": "tests/fixture/database/migrations/2016_11_01_131415_create_posts_table.php",
    "chars": 646,
    "preview": "<?php\n\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Fa"
  }
]

// ... and 9 more files (download for full content)

About this extraction

This page contains the full source code of the dmitry-ivanov/laravel-db-profiler GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 29 files (22.0 KB), approximately 6.5k tokens, and a symbol index with 36 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!