Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Dbal Laravel Package

devture/dbal

devture/dbal is a lightweight PHP database abstraction layer built on top of Doctrine DBAL, offering Laravel-friendly helpers for connections, query execution, and transaction handling. Ideal when you want DBAL features without pulling in a full ORM.

View on GitHub
Deep Wiki
Context7

Tiny database abstraction layer for MongoDB (doctrine/mongodb) and relational databases (doctrine/dbal)

Frequently asked questions about Dbal
Can I use devture/dbal to run MongoDB and SQL queries in the same Laravel transaction?
No, this package doesn’t natively support distributed transactions across MongoDB and SQL. It provides unified query execution but relies on each database’s native transaction isolation. For ACID compliance, design your workflows to handle eventual consistency or use database-specific transactions.
How do I install devture/dbal in a Laravel project?
Run `composer require devture/dbal` and configure Doctrine DBAL and MongoDB ODM connections in your `config/database.php`. The package doesn’t include Laravel-specific bindings, so you’ll need to manually register connections or create a custom service provider to integrate with Laravel’s IoC container.
Does devture/dbal work with Laravel’s Eloquent ORM?
Not directly. Eloquent’s active record pattern conflicts with DBAL’s data mapper approach. You can use DBAL for raw queries or complex operations while keeping Eloquent for CRUD, but you’ll need to design adapters or hybrid repositories to bridge the two. Avoid mixing them in the same model layer.
What Laravel versions does devture/dbal support?
The package doesn’t enforce Laravel version constraints, but it depends on Doctrine DBAL 3.x and MongoDB ODM 2.x. Test compatibility with your Laravel version (8.x, 9.x, or 10.x) by checking for breaking changes in Doctrine’s dependencies. Laravel 7 or earlier may require additional adjustments.
How do I write a query that works for both MongoDB and SQL with devture/dbal?
Use Doctrine’s abstract QueryBuilder or platform-specific queries with conditional logic. For example, check the connection type (`$connection->getDatabasePlatform()`) and adapt syntax (e.g., `WHERE` for SQL vs. `$match` for MongoDB). Avoid porting Laravel’s Query Builder syntax directly—it’s not designed for this.
Is devture/dbal suitable for production if I only need MongoDB?
No, this package adds unnecessary complexity for single-database use cases. If you’re using MongoDB exclusively, stick with Laravel’s native MongoDB support (via `jenssegers/mongodb` or Eloquent for MongoDB) or Doctrine MongoDB ODM directly. The abstraction layer is only valuable for polyglot persistence.
Can I use Laravel Migrations with devture/dbal for MongoDB schemas?
No, Laravel Migrations only support SQL databases. For MongoDB schema changes, use custom scripts or a package like `doctrine/mongodb-odm-module` for migrations. You’ll need to manage MongoDB schema updates separately or build a hybrid migration system.
What are the performance implications of using devture/dbal?
The overhead is minimal for simple queries, as it delegates to Doctrine DBAL/MongoDB ODM. However, complex queries or joins across databases may introduce latency due to abstraction layers. Benchmark against raw drivers if performance is critical, especially for read-heavy workloads.
Are there alternatives to devture/dbal for Laravel polyglot persistence?
Yes. For SQL + MongoDB, consider `jenssegers/mongodb` (Laravel-specific MongoDB integration) paired with raw PDO for SQL, or build a custom repository layer. For full ORM support, evaluate `doctrine/orm` (SQL) + `doctrine/mongodb-odm` (NoSQL), though this increases complexity. This package is unique in its DBAL-centric approach.
How do I handle errors or debug queries when using devture/dbal?
Use Doctrine’s built-in logging (configure via `doctrine/dbal` or `doctrine/mongodb-odm`) or wrap queries in try-catch blocks to catch exceptions. Laravel’s `DB::enableQueryLog()` won’t work directly—you’ll need to log queries manually or extend the package. Check the underlying connection’s error modes for detailed diagnostics.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky