yiisoft/db-sqlite
SQLite driver for the Yii Database library, providing connection handling, schema introspection, query building, and ActiveRecord support for SQLite-backed Yii applications.
Architecture fit
yiisoft/db-sqlite 2.0.0 — the SQLite driver for the Yii3 database abstraction (yiisoft/db), not a Laravel/Eloquent driver. It does not integrate with Illuminate\Database, Laravel's query builder, Eloquent, migrations, or DB:: facades.ConnectionInterface, SchemaInterface, CommandInterface, QueryBuilder, ColumnInterface, ColumnBuilder, ColumnFactory, ColumnDefinitionBuilder, SqlParser, QuoterInterface.Illuminate\Database + sqlite3/PDO.ColumnFactory, ColumnBuilder, ColumnDefinitionBuilder, and typed ColumnSchemaInterface implementations (cast-per-datatype for performance). This is a cleaner design, but it is a substantially different extension surface from 1.x.Integration feasibility
yiisoft/db and PHP 8.1–8.5. Laravel 10/11 ships ^8.1/^8.2, so PHP is generally compatible; the constraint that bites is the paired yiisoft/db major and its transitive PSR expectations.Log) and PSR-16 (Cache) adapters, but does not ship a PSR-17 HTTP factory by default — a nyholm/psr7 (or equivalent) binding is likely required in AppServiceProvider. Verify against yiisoft/db's data-source/DSN construction path after the Dsn refactor (#323, #373).Connection with logger, cache, and HTTP factory, plus manual lifecycle handling (no DB::transaction() integration; use ConnectionInterface::createTransaction(), now more specifically typed per #324).Connection instance — need explicit singleton scoping and a post-fork/reload strategy.Technical risk
TableSchema class removed; Schema refactored (#377), loadResultColumn() added (#348).ColumnInterface originally removed (#332) then ColumnSchemaInterface renamed to ColumnInterface (#334) — any custom column classes must be re-based on the new typed hierarchy (DateTimeColumn, enum column support #404, collation #380).QueryBuilder constructor changed (#330); expression namespaces relocated per yiisoft/db (#391); hasLimit()/hasOffset() usage removed (#342).Command::insertWithReturningPks() now returns array|false (#339) — a falsy return can silently mask a failed insert if callers only check truthiness.unsigned column usage now throws (#402) rather than being tolerated — schema definitions ported from MySQL-flavored migrations may fail at runtime.yiisoft/json dependency (#343); JsonExpressionBuilder and JSON tests moved to yiisoft/db (#337) — JSON behavior is now owned upstream, so version-pinning must move in lockstep.Schema::getCacheKey()/getCacheTag() removed (#347) — any schema-caching integration built on those hooks must be rebuilt.catch blocks targeting Yiisoft\Db\Exception\InvalidArgumentException will no longer match.yiisoft/db, yiisoft/db-sqlite, and any active record/ORM layer above them must move together. There is no partial-upgrade path.yiisoft/db major.upsertReturning() (#356/#357), insertReturningPks() (#360/#361), FOR clause (#354), JSON OVERLAPS (#310/#393), caseSensitive LIKE option (#344), and ArrayMerge/Greatest/Least builders (#384/#390) are welcome capabilities but expand the test matrix — particularly FOR UPDATE, which SQLite does not truly support and whose behavior should be characterized before relying on it.Key questions
yiisoft/db version does 2.0.0 require, and is that constraint satisfiable alongside the rest of the Composer graph (notably PSR-7/17 implementations and any existing yiisoft/json consumers)?Stack fit
Yiisoft\Db\Sqlite\Connection as a singleton for a scoped set of jobs/services; Eloquent remains the system of record. Lowest blast radius, highest conceptual overhead.RefreshDatabase, and Telescope/query-log integration for no compensating benefit.SqliteReportRepository, LegacyLedgerReader) and keep every Yiisoft\Db\* type behind it. This contains the next major-version churn to a single directory.Migration path
yiisoft/db and yiisoft/db-sqlite to compatible 2.x majors in one commit; expect the resolver to reject intermediate combinations.getRawTableName, getCacheKey, getCacheTag, ColumnSchemaInterface, TableSchema, hasLimit, hasOffset, unsigned, and Yiisoft\Db\Exception\InvalidArgumentException.ColumnSchemaInterface hierarchy and route SQL generation through ColumnDefinitionBuilder.QueryBuilder construction sites for the new constructor signature.insertWithReturningPks() caller for the new array|false contract.Compatibility
^8.1, matching yiisoft/db 2.x, a PSR-17 HTTP factory (nyholm/psr7 recommended for Laravel), PSR-3 logger and PSR-16 cache (both already available via Laravel adapters).yiisoft/db-implementation virtual package (#368) means Composer will permit only one concrete driver implementation per install — verify this does not conflict with any other Yii DB driver already in the graph.unsigned (now throws, per #402), FOR UPDATE has no meaningful semantics, and returning-clause support depends on the bundled SQLite version (3.35+ for RETURNING). Confirm the runtime libsqlite3 version in your container images, not just locally.Sequencing
yiisoft/db-sqlite 2.x + yiisoft/db 2.x + PSR-17 factory + existing Laravel deps. A failed resolution here is the cheapest possible failure.Connection, PSR-17 binding, logger/cache adapters, DSN construction post-Dsn refactor, configuration in config/database.php (custom key, not the connections array).upsertReturning, caseSensitive LIKE, JSON overlaps, enum columns).array|false return handling.yiisoft/db 3.0 signal.Maintenance
ColumnInterface (#332/#334). Expect another exercise of this size at the next major.yiisoft/db, yiisoft/db-sqlite, and any ORM layer together means a single Dependabot PR becomes a coordinated upgrade — plan for it rather than being surprised by it.Support
yiisoft/db source, and document the wiring decisions in an ADR.@Tigrov, @vjik).Scaling
ColumnSchemaInterface implementations per datatype (#273) reduce casting overhead, and the new ColumnFactory/ColumnDefinitionBuilder split should make schema introspection cheaper. For read-heavy reporting against SQLite, this is a genuine improvement over 1.x.getCacheKey()/getCacheTag() removed (#347), you lose fine-grained invalidation hooks — plan for a coarse TTL or full-flush strategy after schema changes, and make sure that flush is wired into your deploy step.Failure modes
insertWithReturningPks() now returns array|false (#339). Code written against 1.x that assumes an array will misbehave. Enforce strict comparison and treat false as a hard error.` to " (#362). Untraced raw SQL fails at runtime, often only on the code path that uses it. Mitigate with a repo-wide grep as a CI lint.FOR UPDATE on SQLite. (#354) The clause parses but SQLite has no row-level locking. Developers porting from PostgreSQL may believe they have a lock they do not have. Document this explicitly, or forbid the clause in code review.JsonExpressionBuilder moved to yiisoft/db (#337) and yiisoft/json was dropped (#343). A stale pin can leave JSON handling on the wrong package version. Verify JSON round-trip and OVERLAPS semantics in staging.SQLITE_BUSY. Set a busy timeout and retry policy, or separate the files.catch blocks keyed on the old exception class stop catching. Audit error paths; consider catching \Throwable at the adapter boundary and re-throwing domain exceptions.yiisoft/db 2.x pins can block unrelated upgrades. Isolating the package behind an adapter keeps the rest of the app free to move.Ramp-up
How can I help you explore Laravel packages today?