- What is dbt/odbc-driver and what does it do?
- dbt/odbc-driver is a Laravel 12+ service provider that registers an ODBC-backed database connector. After installation, DB::connection('odbc') returns a connection that supports Laravel's query builder and Eloquent models, letting you query ODBC DSNs through familiar database APIs. It is purely additive, so your existing connections are unaffected.
- How do I install and configure dbt/odbc-driver in Laravel?
- Run composer require dbt/odbc-driver; the service provider is auto-discovered. Add a connections.odbc entry in config/database.php with the driver set to odbc and your DSN or DSN-less connection string, and keep credentials in .env. You must also install unixODBC and the vendor ODBC driver on every environment that will open the connection.
- Which Laravel and PHP versions does dbt/odbc-driver support?
- It targets Laravel 12+ only and assumes PHP 8.2+. That pins you to the newest Laravel major, so a future Laravel 13 upgrade will likely require a package release that may not arrive. Check that Packagist tags resolve before relying on the release metadata.
- Should I use dbt/odbc-driver for SQL Server, MySQL, or PostgreSQL?
- No for SQL Server, MySQL, and PostgreSQL. Use sqlsrv or pdo_sqlsrv for SQL Server and native drivers for MySQL and PostgreSQL, because those are vendor-supported and faster. Use this package only where ODBC is the sanctioned path, such as DB2 for i or z, Sybase ASE, Pervasive/Btrieve, legacy Oracle where Instant Client is disallowed, warehouse ODBC endpoints, or corporate environments that only permit unixODBC DSNs.
- Does dbt/odbc-driver support Eloquent, transactions, and migrations?
- Query builder and Eloquent access are the core promise; schema builder, migrations, transactions, upsert, insertGetId, lockForUpdate, JSON columns, LOB reads, LIMIT/OFFSET emulation, and rowCount fidelity are claim-dependent over ODBC. Verify each feature against your exact DBMS and driver version before committing to a design. Schema introspection and insert ID retrieval are the most likely to be partial.
- What infrastructure is required to run ODBC connections in Laravel?
- You need unixODBC plus the vendor driver, such as msodbcsql18, IBM iAccess, Oracle Instant Client, or Snowflake ODBC, on dev, CI, staging, production, queue workers, and cron containers. Architecture must match (amd64 versus arm64), and you must decide between DSN entries in odbc.ini and DSN-less connection strings. Credentials often end up split between .env and odbc.ini, so document the setup.
- What are the production risks of using dbt/odbc-driver?
- The main risks are a native-crash blast radius, an unverified feature surface, and a bus factor of one: the project has roughly 29 stars, zero dependents, and a single maintainer. A segfault or OOM inside the driver manager or vendor .so kills the PHP worker without a catchable exception or stack trace. ODBC round-trips and uneven prepared-statement reuse also make N+1 Eloquent patterns degrade sharply.
- Does dbt/odbc-driver work with queue workers and long-lived connections?
- It is unproven. Test whether the connection survives long-lived queue workers and whether it reconnects after a stale handle, since that behavior is not documented here. Also test statement timeout and cancel semantics, because a hung query may only be abortable by killing the worker.
- How should I test dbt/odbc-driver before rolling it out?
- Start with an isolated branch or spike, not production. Confirm the transport (pdo_odbc versus native odbc), whether PDO::ATTR_EMULATE_PREPARES is forced, and which DBMS and driver versions are actually tested. Prefer a CI matrix with real ODBC containers over mocked unit tests, and exercise migrations, transactions, upsert, and LOB reads if you need them.
- What alternatives are there to dbt/odbc-driver for ODBC in Laravel?
- Prefer native Laravel drivers wherever they exist, including sqlsrv and pdo_sqlsrv for SQL Server. If you must use ODBC, you can also build your own connector through DB::extend() with custom Connector, Connection, and Grammar classes, which keeps you in control of the semantics. The package is MIT licensed and small enough that vendoring and owning it outright is a viable fallback.