Doctrine DBAL
A PHP database abstraction layer with a fluent query builder and schema introspection across major RDBMS engines
Repository Health
Technical Analysis
Doctrine DBAL is a thin abstraction layer over PHP’s PDO (and native driver) extensions, giving applications one consistent API for connecting to and querying MySQL, PostgreSQL, SQLite, Oracle, SQL Server, MariaDB, IBM DB2, and more. Rather than writing raw, engine-specific SQL, developers use its fluent QueryBuilder to construct SELECT/INSERT/UPDATE/DELETE statements, and its Platforms layer translates DBAL’s neutral SQL into the correct dialect for whichever database is configured.
Beyond query execution, DBAL includes a Schema component for introspecting and diffing database structure (tables, columns, indexes, foreign keys) programmatically, which is what powers Doctrine ORM’s migrations and schema-sync tooling — though DBAL itself is fully usable standalone, without adopting the full ORM.
What You Get
- A fluent
QueryBuilderfor constructing SELECT/INSERT/UPDATE/DELETE queries programmatically - A
Platformsabstraction that translates neutral SQL into the correct dialect per database engine - A
Schemacomponent for introspecting and diffing tables, columns, indexes, and foreign keys - A
Typessystem mapping PHP types to database column types consistently across platforms - Connection management, transaction handling, and portability helpers (case normalization, etc.)
- Support for MySQL/MariaDB, PostgreSQL, SQLite, Oracle, SQL Server, and IBM DB2
Common Use Cases
- Writing database queries that need to run unchanged across multiple RDBMS engines
- Building or running Doctrine ORM’s schema migrations and diffing tooling
- Introspecting an existing database’s schema programmatically for tooling or codegen
- Using a query builder for raw SQL access without adopting a full ORM’s entity-mapping layer
Under The Hood
Architecture - Connection.php wraps a Driver (in src/Driver/) that adapts PDO or native extensions per engine, Query.php/Query/QueryBuilder builds abstract syntax that the matching Platforms/*Platform.php class renders into engine-specific SQL, while Schema/ provides Table/Column/SchemaDiff classes that introspect live databases via platform-specific SchemaManager implementations. Tech Stack - Modern PHP (8.1+) with strict static analysis enforced via PHPStan (phpstan-baseline.neon, phpstan.neon.dist) and coding-standard checks via PHP_CodeSniffer, packaged and versioned through Composer, part of the broader Doctrine project ecosystem. Code Quality - A 20+ directory tests/ suite covering functional tests per platform and unit tests per component, combined with a strict static-analysis baseline and a documented UPGRADE.md for every major version, reflects mature, disciplined engineering across 649 contributors. API Design - The QueryBuilder’s fluent, chainable methods (->select()->from()->where()) closely mirror SQL itself, keeping the learning curve low for anyone who already knows SQL, while the Schema/Types layers require more study to use well for advanced introspection or custom type mapping.
Used by 13 apps in this directory
Akaunting
Invoicing Finance
Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.
Coolify
Devops · Hosting Control Panel
Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in
Crater
Invoicing Finance
Open source invoicing and billing platform for freelancers and small businesses — create estimates, track expenses, accept Stripe payments, and run recurring invoices from your own server.
EspoCRM
Marketing · Ecommerce · CRM
Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.
FreeScout
Customer Support
Run your own help desk and shared inbox — a fully self-hosted, open-source alternative to Zendesk and Help Scout with no per-agent fees.
Hi.Events
Ecommerce · Scheduling
Self-hosted event ticketing platform that keeps your attendee data, brand, and revenue completely under your control.
Hyvor Relay
Devops · AI Development · Monitoring
Self-hosted, open-source email API that automates DNS, manages SMTP delivery, and provides deep observability — replacing SES, Mailgun, and SendGrid with infrastructure you fully own.
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira
LinkStack
Marketing
Self-hosted, privacy-focused Linktree alternative with themes, analytics, and a drag-and-drop admin panel.