Weave 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

Db Laravel Package

yiisoft/db

Yii Database is a framework-agnostic PHP library for database access. It offers a PDO-based abstraction layer, fluent query builder, schema introspection, transactions, and batch inserts, with drivers for MySQL, PostgreSQL, SQLite, SQL Server, Oracle, and others.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy on the data-access layer. This is a ready-made, framework-agnostic database abstraction: connection handling, a typed query builder, schema introspection, transactions, batch inserts, and multi-driver support (MySQL, PostgreSQL, SQLite, SQL Server, Oracle). The decision it informs is "do we hand-roll or maintain our own PDO wrapper?" — and the answer is usually no. Note the framing risk: this is not a Laravel package. On a Laravel codebase it duplicates Illuminate\Database/Eloquent, so the decision flips to "justify a parallel abstraction," which is rarely worth it.
  • Database-portability roadmap. If the product must ship against more than one engine — SaaS on Postgres, self-hosted/on-prem on MySQL or SQLite, or embedded appliances — a single abstraction dramatically lowers the cost of supporting the second and third backend. This is the package's strongest strategic argument.
  • Migrations and deployment automation. Schema-as-code and versioned migrations support release-engineering decisions: how do we roll forward in production, how do we keep dev/staging/prod schemas honest, how much manual DBA work do we absorb?
  • Ecosystem/stack consolidation. Relevant to teams already on Yii2 or moving to Yii3: it's the sanctioned path for extracting data access out of a monolith, or for keeping shared data code portable across a Yii service and a non-Yii service.
  • Use cases that fit well: internal admin tooling, background/CLI batch jobs and ETL, legacy maintenance, multi-tenant services where a thin, explicit SQL layer beats a heavy ORM, and small services that want Active Record only as an optional add-on.
  • What it should not drive: an ORM strategy decision. Active Record and migrations live in sibling packages; if the product needs a rich domain model with identity maps and lazy loading, this is a component, not a substitute.

When to Consider This Package

Adopt when most of these are true:

  • The codebase is, or will be, Yii3 (or you're maintaining Yii2 and want a forward path), so the package is the native choice rather than a foreign dependency.
  • You need one data layer across several DB engines, and keeping per-dialect code in sync is a real, recurring cost.
  • You want an explicit SQL-first API with parameter binding and no ORM magic — teams that prefer predictable queries over generated ones.
  • You need bundled schema management (introspection, table/column definitions, index and FK handling) rather than assembling three libraries.
  • A permissive license with no procurement friction matters — BSD-3-Clause is commercially safe and modification-friendly.
  • You're comfortable being an early-ish adopter: ~215 stars and a low opportunity score signal a thin community, so you should expect to read source and own your own support. That is acceptable for a bounded, well-tested component; it is not acceptable for a critical path with no in-house PHP depth.

Look elsewhere when:

  • You're on Laravel. Eloquent and the DB facade already cover this ground; adding yiisoft/db means two query layers, two connection configs, and lost model events, soft deletes, and relationship tooling. Only justified for a genuinely framework-neutral shared library, and even then Doctrine DBAL is the more common neutral pick.
  • You're a Doctrine shop (DBAL/ORM), where DBAL already provides the portability and schema tooling.
  • You need a mature ecosystem: first-party integrations, Stack Overflow answers, hiring pool, long-term commercial support. This package does not offer those.
  • The requirement is really an ORM or query-builder-on-steroids (eager loading, unit of work, entity mapping) — that's a different purchase.
  • You need advanced connection features out of the box — sophisticated read/write splitting, pooling, failover — where a dedicated proxy or driver-level solution is the better answer.

How to Pitch It (Stakeholders)

For executives (one paragraph): We evaluated yiisoft/db, the Yii database library, as a candidate data-access layer. It's a BSD-licensed, production-shaped component that gives us one API for MySQL, PostgreSQL, SQLite, SQL Server, and Oracle, plus schema and transaction tooling — meaning we write database code once instead of once per engine. The commercial case is straightforward: no license cost, no procurement, and a materially lower cost to support a second or third database if the roadmap calls for it. The honest caveat is community size: roughly 215 GitHub stars means we would be largely self-supporting, so the recommendation is a timeboxed proof of concept on one non-critical service before any broader commitment — not a platform-wide standard.

For engineering (the substance): It's a thin, PDO-based abstraction with a typed query builder, parameterized statements, transactional helpers, batch inserts, and schema introspection across the major engines. If we're building on Yii3, this is the intended path and we get it for free. If we're on Laravel, be explicit that this replaces parts of Eloquent rather than complementing it — we'd be trading model events, relationships, and soft deletes for portability we may not need. The realistic adoption test is a single service that genuinely must run on two engines; if that test doesn't produce a clear win, we default to the framework-native layer.

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.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle