Doctrine DBAL

A PHP database abstraction layer with a fluent query builder and schema introspection across major RDBMS engines

Library
Composer
v4.4.4
9,700stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
93/100Excellent
Development Activity96
Maintenance96
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture85
Code Quality88
Innovation60
Learning Curve65

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 QueryBuilder for constructing SELECT/INSERT/UPDATE/DELETE queries programmatically
  • A Platforms abstraction that translates neutral SQL into the correct dialect per database engine
  • A Schema component for introspecting and diffing tables, columns, indexes, and foreign keys
  • A Types system 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

Other

Akaunting

Invoicing Finance

10,070

Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.

View details
98
Repo Health
73
Technical
63
Dependency
Updated yesterday
PHP
79%
Apache 2.0

Coolify

Devops · Hosting Control Panel

60,738

Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in

View details
92
Repo Health
86
Technical
72
Dependency
Built with
PHP79%
Blade18%
Updated yesterday
PHP
48%
AGPL 3.0

Crater

Invoicing Finance

8,341

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.

View details
54
Repo Health
68
Technical
69
Dependency
Built with
PHP48%
Vue40%
Updated 2 years ago
PHP
66%
AGPL 3.0

EspoCRM

Marketing · Ecommerce · CRM

3,259

Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.

View details
97
Repo Health
72
Technical
64
Dependency
Built with
PHP66%
JavaScript24%
Updated yesterday
PHP
91%
AGPL 3.0

FreeScout

Customer Support

4,484

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.

View details
93
Repo Health
55
Technical
63
Dependency
Built with
PHP91%
Updated yesterday
PHP
57%
Other

Hi.Events

Ecommerce · Scheduling

3,985

Self-hosted event ticketing platform that keeps your attendee data, brand, and revenue completely under your control.

View details
88
Repo Health
84
Technical
67
Dependency
Built with
PHP57%
TypeScript37%
Updated 6 days ago
PHP
63%
AGPL 3.0

Hyvor Relay

Devops · AI Development · Monitoring

819

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.

View details
69
Repo Health
79
Technical
70
Dependency
Built with
PHP63%
Svelte23%
Go12%
Updated today
PHP
48%
AGPL 3.0

Leantime

Productivity · Project Management · Collaboration

11,391

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
67
Dependency
Built with
PHP48%
CSS20%
Blade17%
Updated 4 days ago
PHP
65%
AGPL 3.0

LinkStack

Marketing

3,797

Self-hosted, privacy-focused Linktree alternative with themes, analytics, and a drag-and-drop admin panel.

View details
75
Repo Health
56
Technical
68
Dependency
Built with
PHP65%
Blade35%
Updated 4 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search