spam-n-eggs/laravel-mysqlite
A Laravel package that adds a MySQLite database driver, combining SQLite's lightweight footprint with MySQL-style compatibility for local development and testing. Install via Composer and configure it through Laravel's standard database connections.
laravel-mysqlite (dominion-solutions/laravel-mysqlite) registers a mysqlite database driver: a SQLite connection wrapped in MySQL-compatible schema/query grammars. The point is to run your MySQL-targeted test suite against in-memory SQLite without maintaining a parallel set of migrations or a MySQL service in CI.
Minimal setup:
composer require --dev dominion-solutions/laravel-mysqlite
Add a connection in config/database.php (the package ships a publishable config you can inspect with php artisan vendor:publish --tag=mysqlite-config):
'mysqlite' => [
'driver' => 'mysqlite',
'database' => ':memory:',
'prefix' => '',
'foreign_key_constraints' => true,
],
Then point tests at it in phpunit.xml:
<env name="DB_CONNECTION" value="mysqlite"/>
Where to look first: the package's service provider (driver registration), its schema grammar class (this is where MySQL-vs-SQLite translation lives), and config/mysqlite.php for toggles. Your first use case should be a single feature test using RefreshDatabase against the new connection — that tells you immediately whether your migrations are within the supported subset.
Keep MySQL in production, MySQLite in tests. Do not swap the connection in application code. Leave DB_CONNECTION=mysql in .env, override only in phpunit.xml / phpunit.xml.dist, and let the test suite resolve the emulated driver.
Use RefreshDatabase per test class, not per test. In-memory SQLite is fast but the migration run is the expensive part. Standard RefreshDatabase with transactions gives you isolation without re-migrating for every method.
Prefer :memory: for unit/feature tests, a file for debugging. When a query behaves differently than expected, switch database to a temp file path so you can open it with sqlite3 and inspect the actual DDL the grammar produced. This is the single most effective debugging technique with this package.
Isolate MySQL-specific assertions. If a test genuinely depends on MySQL semantics (FULLTEXT relevance ordering, ON DUPLICATE KEY UPDATE edge cases, JSON path behavior), mark it with a group and run it only against real MySQL in a separate CI job. Don't force MySQLite to prove MySQL behavior it only approximates.
CI matrix. Run the MySQLite job on the PHP/Laravel versions you actually support, and keep one real-MySQL job as the source of truth. As of v2.0.2 the package's own CI covers Laravel 11, so that combination is a reasonable default for new projects; on older Laravel versions pin to the release line you validated.
Seeding and factories work unchanged — factories hit Eloquent, not the grammar, so only raw/schema-level MySQL syntax is at risk.
bootstrap/cache/config.php after install and after changing the connection block.php artisan config:cache in a test bootstrap can freeze the wrong DB_CONNECTION. Don't cache config in the test environment.DB::statement() calls with MySQL-only syntax, FULLTEXT indexes, generated columns, and certain ALTER TABLE combinations are the usual breakages. Audit migrations that use DB::statement first.PRAGMA foreign_keys=ON; verify foreign_key_constraints is true in the connection config or FK-violation tests will silently pass.NOW(), DATE_FORMAT, and case-insensitive LIKE differ. Use Carbon in tests and avoid asserting on DB-side date formatting.How can I help you explore Laravel packages today?