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

Laminas Db Laravel Package

laminas/laminas-db

Database abstraction and SQL builder for PHP. Provides adapters, connection management, query/statement execution, metadata and schema tools, result sets, and a fluent API for composing SQL across multiple database platforms.

View on GitHub
Deep Wiki
Context7

Database abstraction layer, SQL abstraction, result set abstraction, and RowDataGateway and TableDataGateway implementations

Frequently asked questions about Laminas Db
Can I use laminas-db in a Laravel project alongside Eloquent or Query Builder?
Yes, laminas-db can coexist with Laravel’s Query Builder or Eloquent, but integration requires effort. You’ll need to manually bridge connections (e.g., via custom adapters) since Laminas doesn’t natively integrate with Laravel’s `DatabaseManager`. Use cases like bulk operations or legacy codebases benefit most from this hybrid approach.
What Laravel versions does laminas-db support, and are there compatibility issues?
Laminas DB doesn’t enforce Laravel-specific dependencies, so it *technically* works with most Laravel versions. However, its **security-only maintenance** means no guarantees for PHP 8.2+ or Laravel 10+ features. Test thoroughly, especially if using newer database drivers or connection pooling.
How do I migrate a legacy PHP app using Laminas DB into Laravel?
Start by wrapping Laminas’ `TableDataGateway` or `RowDataGateway` in Laravel service providers. Use Laravel’s `Connection` facade to delegate queries to Laminas’ adapters. For transactions, ensure Laminas’ `Transaction` class aligns with Laravel’s `DB::transaction()` expectations—manual error handling may be needed.
Is laminas-db a good choice for multi-database workloads (e.g., PostgreSQL + MySQL) in Laravel?
Yes, but with caveats. Laminas supports multiple drivers natively, but Laravel’s `DatabaseManager` won’t auto-detect Laminas connections. You’ll need to configure custom connection resolvers. For production, benchmark performance—abstraction layers can introduce slight overhead in polyglot setups.
What are the security risks of using laminas-db in production, given it’s in security-only mode?
The primary risk is unpatched vulnerabilities in dependencies (e.g., PDO drivers). Since no new features are added, critical updates for PHP/Laravel may never arrive. Mitigate by isolating usage (e.g., background jobs) or forking the repo to backport fixes. Regularly audit dependencies with `composer audit`.
How does laminas-db’s SQL abstraction compare to Laravel’s Query Builder for complex queries?
Laminas offers a **fluent, object-oriented API** (e.g., `Select::from()->where()->join()`) similar to Laravel’s chaining but with stricter type safety. It excels for **dynamic SQL** (e.g., reporting queries with nested joins) where Laravel’s builder feels verbose. For simple CRUD, Laravel’s Query Builder is more idiomatic.
Can I mock laminas-db for Laravel unit tests without Laravel-specific tools?
Yes, Laminas provides mockable interfaces like `ResultSetInterface` and `AdapterInterface`. Use PHPUnit’s mock builder to stub `TableGateway` or `RowGateway` methods. For Laravel tests, wrap Laminas objects in a service layer to decouple them from Laravel’s `DB` facade, making mocks easier.
Are there alternatives to laminas-db for Laravel that offer active maintenance?
For database abstraction, consider **Doctrine DBAL** (mature, actively maintained) or **Laravel’s own Query Builder extensions** (e.g., custom macros). If you need gateway patterns, **Doctrine ORM** or **Eloquent’s accessors/mutators** might suffice. Avoid deprecated packages like `ZendDb` (Laminas’ predecessor).
How do I configure laminas-db to work with Laravel’s config/database.php connections?
Laminas doesn’t read Laravel’s config natively, so you’ll need a **custom connection resolver**. Extend Laravel’s `Connection` class to instantiate Laminas’ `Adapter` with your DSN, then register it in `config/app.php` under `connections`. Example: `laminas => function() { return new LaminasDbConnection($config['laminas']); }`.
Will laminas-db work with Laravel’s first-party features like migrations or model events?
No, laminas-db doesn’t integrate with Laravel migrations or Eloquent events. For migrations, use Laravel’s native system or a custom adapter. Model events (e.g., `saved`) won’t trigger automatically—you’ll need to manually hook into Laminas’ `TableGateway` callbacks or use Laravel’s `Observers` on a wrapper class.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata