slam / dbal-debugstack-middleware
Doctrine\DBAL middleware for precise query debugging (DebugStack replacement)
Fund package maintenance!
Slamdunk
paypal.me/filippotessarotto
Installs: 3 819
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: ~8.3.0 || ~8.4.0
- doctrine/dbal: ^4.1.1
Requires (Dev)
- phpstan/phpstan: ^1.12.4
- phpstan/phpstan-phpunit: ^1.4.0
- phpstan/phpstan-strict-rules: ^1.6.1
- phpunit/phpunit: ^11.3.6
- slam/php-cs-fixer-extensions: ^3.12.0
This package is auto-updated.
Last update: 2024-11-11 13:23:01 UTC
README
Doctrine\DBAL middleware for precise query debugging (DebugStack replacement). Compared to the default logging middleware, this one:
- Tracks the query's execution time
- Doesn't handle exceptions
- Doesn't track disconnections
Installation
composer require slam/dbal-debugstack-middleware
Usage
use Doctrine\DBAL\Configuration; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\ParameterType; use Slam\DbalDebugstackMiddleware\DebugStack; use Slam\DbalDebugstackMiddleware\Middleware; $debugStack = new DebugStack(); $conn = DriverManager::getConnection( $connectionParams, (new Configuration)->setMiddlewares([ new Middleware($debugStack) ]) ); $result = $conn->executeQuery( 'SELECT * FROM users WHERE active = :active', ['active' => true], ['active' => ParameterType::BOOLEAN], ); print_r($debugStack->getQueries()); /* * Output: * Array ( [0] => Slam\DbalDebugstackMiddleware\Query Object ( [sql] => SELECT * FROM users WHERE active = :active [params] => Array ( [active] => true ) [types] => Array ( [active] => 5 ) [executionMs] => 72.05312 ) ) */