cadre / atlasorm-debugbar-bridge
Library to use PHP DebugBar with Atlas ORM
Installs: 107
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/cadre/atlasorm-debugbar-bridge
Requires (Dev)
- atlas/orm: ^1.3.0
- maximebf/debugbar: ^1.13.0
- pds/skeleton: ^1.0.0
- phing/phing: ^2.16.0
- phpstan/phpstan: ^0.7.0
- phpunit/phpunit: ^6.2.3
- squizlabs/php_codesniffer: ^3.0.1
README
Read the instructions for using Atlas.Orm and PHP Debug Bar. I'll just show you what you need to do to make these work together.
1. Include Atlas.Orm and PHP Debug Bar in your project
I'm not listing either of these as a dependency of this library because I'll let you define what version and stability you want in your project.
2. Use Cadre\AtlasOrmDebugBarBridge\AtlasContainer
Instead of using the normal Atlas\Orm\AtlasContainer use
Cadre\AtlasOrmDebugBarBridge\AtlasContainer.
This class functions exactly as the normal Atlas.ORM one only it uses
Cadre\AtlasOrmDebugBarBridge\ExtendedPdo instead of
Aura\Sql\ExtendedPdo which wraps the inner PDO object in
DebugBar\DataCollector\PDO\TraceablePDO.
3. Use Cadre\AtlasOrmDebugBarBridge\AtlasOrmCollector
I've provided Cadre\AtlasOrmDebugBarBridge\AtlasOrmCollector which takes
a Cadre\AtlasOrmDebugBarBridge\AtlasContainer, pulls the
DebugBar\DataCollector\PDO\TraceablePDO object out of it and passes it up
to its parent DebugBar\DataCollector\PDO\PDOCollector.
Example
$atlasContainer = new Cadre\AtlasOrmDebugBarBridge\AtlasContainer( 'mysql:host=localhost;dbname=testdb', 'username', 'password' ); $debugbar = new DebugBar\StandardDebugBar(); $debugbar->addCollector( new Cadre\AtlasOrmDebugBarBridge\AtlasOrmCollector($atlasContainer) );
Multiple Connections
$atlasContainer = Cadre\AtlasOrmDebugBarBridge\AtlasContainer( 'mysql:host=localhost;dbname=testdb', 'username', 'password' ); $factory = new Cadre\AtlasOrmDebugBarBridge\ConnectionFactory( 'mysql:host=localhost;dbname=slavedb', 'readonly', 'password' ); $atlasContainer->setReadConnection('readonly', $factory); $collector = new Cadre\AtlasOrmDebugBarBridge\AtlasOrmCollector($container); $collector->addConnectionFactory($factory, 'readonly'); $debugbar = new DebugBar\StandardDebugBar(); $debugbar->addCollector($collector);