eznix86/laravel-sqlite

Optimize SQLite for Laravel

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 1

pkg:composer/eznix86/laravel-sqlite

v1.0.0 2026-02-20 21:02 UTC

This package is auto-updated.

Last update: 2026-02-20 21:30:09 UTC


README

Optimize SQLite Banner

Optimize SQLite for Laravel in production.

This package exists to give SQLite-first Laravel apps explicit control over performance PRAGMAs, maintenance commands, and migration-time file behavior.

Features

  • Multi SQLite Connection Support
  • Configurable SQLite PRAGMAs
  • Supports Litestream Package
  • Handles migration command startup to prepare missing SQLite files/directories.

Requirements

  • PHP ^8.4
  • Laravel 12.x (package is built/tested against the Laravel 12 ecosystem)

Installation

composer require eznix86/laravel-sqlite

Publish the config file:

php artisan vendor:publish --tag=sqlite-config

Configuration

Configuration lives in config/sqlite.php.

Key options:

  • sqlite.enabled - enable/disable package PRAGMA application.
  • sqlite.litestream - Litestream-safe mode (forces wal_autocheckpoint=0).
  • sqlite.pragmas.incremental_vacuum
  • sqlite.pragmas.temp_store
  • sqlite.pragmas.cache_size_mb
  • sqlite.pragmas.mmap_size_mb
  • sqlite.pragmas.wal_autocheckpoint

Environment variable prefix: SQLITE_...

Commands

Vacuum

Run full VACUUM on SQLite connections:

php artisan sqlite:vacuum
php artisan sqlite:vacuum --connection=sqlite

Notes:

  • Without --connection, it runs on all configured SQLite connections.
  • If sqlite.litestream=true, the command is blocked by design.

Show PRAGMAs

Display configuration and runtime PRAGMA values:

php artisan sqlite:show-pragmas
php artisan sqlite:show-pragmas sqlite

Manually Cache / Clear PRAGMA SQL

php artisan sqlite:cache-pragmas
php artisan sqlite:clear-pragmas-cache

These are also connected to Laravel optimize commands:

  • php artisan optimize -> caches PRAGMA SQL
  • php artisan optimize:clear -> clears PRAGMA SQL cache

Migration Behavior

The package listens for commands and prepares SQLite file connections automatically:

  • For migrate* and db:wipe: ensures database files/directories exist (except :memory:).
  • For migrate:fresh: removes the SQLite file and sidecars (-wal, -shm, -journal) first, then recreates the database file.
  • If --database=... is provided, only that SQLite connection is targeted.

Litestream Support

If you want to back up and replicate your SQLite database with Litestream. Use eznix86/laravel-litestream:

Development

composer test:types
composer refactor
composer lint
composer lint:fix
composer test

Notes:

  • This package currently uses feature-style tests; there is no dedicated test:unit script.

License

MIT