- How do I install phpro/dbal-tools in a Laravel application?
- Install it with Composer using composer require phpro/dbal-tools. Laravel package auto-discovery will register the service provider in a standard application; if you disable discovery, add the provider manually. Then verify that your application's PHP, Laravel, and doctrine/dbal versions satisfy the package's declared Composer constraints.
- Which Laravel and PHP versions does phpro/dbal-tools support?
- Support is defined by the package's Composer constraints, not by a fixed Laravel version list in this overview. Check the phpro/dbal-tools composer.json and release notes against your application's PHP and Laravel versions before upgrading. If you run multiple services, align them on the same Laravel and doctrine/dbal versions to avoid divergent behavior.
- How does phpro/dbal-tools build DBAL connections from Laravel's database config?
- The package provides a connection factory that reads your existing Laravel database configuration and creates Doctrine DBAL connections from it. That means you do not need to duplicate host, port, database, username, or password settings in a separate DBAL config file. It is useful when a service already uses Eloquent but needs DBAL APIs for schema introspection or custom SQL.
- Can I create, drop, and update tables with phpro/dbal-tools in Laravel?
- Yes. The package includes schema tools and commands that use Doctrine DBAL's schema manager to create, drop, and update tables. These are useful for DBAL-specific maintenance or controlled schema operations, but they do not replace Laravel migrations for normal application schema changes. Review command behavior in staging before using it on production data.
- Is phpro/dbal-tools a replacement for Laravel Eloquent or the query builder?
- No. phpro/dbal-tools is a Doctrine DBAL companion, not an Eloquent replacement. It adds DBAL connections, custom column types, and typed SQL expressions that Laravel's query builder cannot express directly. It fits best in PostgreSQL-heavy services or code that already uses DBAL, and is marginal in a stock Eloquent application.
- Can phpro/dbal-tools register custom DBAL column types in Laravel?
- Yes. The package provides custom DBAL column types and platform helpers that extend what Laravel's schema builder can express. You typically register those types in a Laravel service provider so DBAL can map them correctly. This is relevant for types such as citext, ltree, enum, or timestamptz in PostgreSQL services.
- Why is JsonbObjectAgg PostgreSQL-only in phpro/dbal-tools?
- JsonbObjectAgg renders PostgreSQL's jsonb_object_agg function, which has no direct MySQL or SQLite equivalent. Any shared code path that uses it must be platform-guarded so non-PostgreSQL connections do not receive invalid SQL. It is intended for PostgreSQL services that already need jsonb aggregation beyond what the query builder provides.
- What are the production risks of using jsonb_object_agg via DBAL tools?
- PostgreSQL's jsonb_object_agg silently keeps the last value when duplicate keys appear, and it errors if a key is null. Both failures depend on runtime data, so they can surface for a specific tenant rather than in CI. Ensure aggregation keys are non-null by schema or application validation, and confirm whether existing queries expect first-value or last-value behavior for duplicates.
- Which doctrine/dbal versions does phpro/dbal-tools 2.15.0 allow?
- Release 2.15.0 widens the Composer constraint to doctrine/dbal ^4.4 || ^4.5. Composer may therefore resolve 4.4 in one service and 4.5 in another until you align your fleet. Pin and align doctrine/dbal versions if custom type behavior or deprecation output must be consistent across applications.
- How should I test a Laravel app that uses phpro/dbal-tools?
- Use a PostgreSQL test database for any code path that exercises JsonbObjectAgg, since MySQL and SQLite cannot execute jsonb_object_agg. Register custom DBAL types in your test bootstrap or service provider so schema and query tests use the same type mappings as production. Add platform-guard tests and run your suite against both doctrine/dbal 4.4 and 4.5 before relying on the widened constraint.