PHPackages                             swiss-devjoy/laravel-optimize-sqlite - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. swiss-devjoy/laravel-optimize-sqlite

ActiveLibrary[Database &amp; ORM](/categories/database)

swiss-devjoy/laravel-optimize-sqlite
====================================

Optimize your SQLite database for production in Laravel

v1.1.0(1mo ago)85.3k↓86.9%MITPHPPHP ^8.2CI passing

Since Apr 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/swiss-devjoy/laravel-optimize-sqlite)[ Packagist](https://packagist.org/packages/swiss-devjoy/laravel-optimize-sqlite)[ Docs](https://github.com/swiss-devjoy/laravel-optimize-sqlite)[ GitHub Sponsors](https://github.com/sponsors/swiss-devjoy)[ RSS](/packages/swiss-devjoy-laravel-optimize-sqlite/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (9)Versions (4)Used By (0)

Optimize your SQLite database for production in Laravel
=======================================================

[](#optimize-your-sqlite-database-for-production-in-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5075c9a5f2a9179e134983d473e7de02ee04480945fa14e3210be3f17810df20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73776973732d6465766a6f792f6c61726176656c2d6f7074696d697a652d73716c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swiss-devjoy/laravel-optimize-sqlite)[![Total Downloads](https://camo.githubusercontent.com/379696894b64bc3d839f9476b6dff9edc9472a1b4d92d3212e86e0a4786a33f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73776973732d6465766a6f792f6c61726176656c2d6f7074696d697a652d73716c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/swiss-devjoy/laravel-optimize-sqlite)

> This package is already used in production in multiple projects. Still, if you want to use this package, **always** backup your database before requiring it through Composer.

This package optimizes your SQLite database for production in Laravel. The settings are applied as soon as any sqlite database connection is established, so you can use them in your application right away.

The current settings are:

```
 ┌───────────────────────────┬─────────────────────┬
 │ Setting                   │ Value               │
 ├───────────────────────────┼─────────────────────┼
 │ PRAGMA auto_vacuum        │ incremental         │
 │ PRAGMA journal_mode       │ WAL                 │
 │ PRAGMA page_size          │ 32768 (32 KB)       │
 │ PRAGMA busy_timeout       │ 5000 (5 seconds)    │
 │ PRAGMA cache_size         │ -20000              │
 │ PRAGMA foreign_keys       │ ON                  │
 │ PRAGMA mmap_size          │ 134217728 (128 MB)  │
 │ PRAGMA temp_store         │ MEMORY              │
 │ PRAGMA synchronous        │ NORMAL              │
 └───────────────────────────┴─────────────────────┘

```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require swiss-devjoy/laravel-optimize-sqlite
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-optimize-sqlite-config"
```

This is the contents of the published config file:

```
return [
    // add, remove or modify SQLite settings to optimize performance. all settings are PRAGMA statements, like "PRAGMA journal_mode = WAL;"
    'general' => [
        'journal_mode' => 'WAL',
        'auto_vacuum' => 'incremental',
        'page_size' => 32768, // 32 KB
        'busy_timeout' => 5000, // 5 seconds
        'cache_size' => -20000,
        'foreign_keys' => 'ON',
        'mmap_size' => 134217728, // 128 MB
        'temp_store' => 'MEMORY',
        'synchronous' => 'NORMAL',
    ],

    // You can override the general settings for specific database connections, defined in config/database.php
    'databases' => [
        'example_connection' => [
            'busy_timeout' => 10000, // override general settings and set 10 seconds
            'temp_store' => null, // unset temp_store from general settings
        ],
    ],
];
```

You can set general settings for all sqlite connections, and override them for specific connections. If you want to remove a general setting, just remove the config line from the config file. If you want to add a new setting, just add it to the config file.

Important notes
---------------

[](#important-notes)

- There is a known issue with databases already in WAL mode and running php artisan migrate:fresh which will throw an error, see [laravel/framework#53044](https://github.com/laravel/framework/discussions/53044)My current alternative is to run a custom composer command (`composer.json`) which refreshes the whole app: ```
      "scripts": {
          "dev-migrate": [
              "Composer\\Config::disableProcessTimeout",
              "rm -f database/*.sqlite",
              "touch database/database.sqlite",
              "@php artisan migrate --seed --ansi",
              "@php artisan cache:clear"
          ]
      },

    ```
- Laravel allows already to set some `PRAGMA` settings in config/database.php which will override the settings in this package. You might want to set those settings to `null` and use this config as sole single source of truth for sqlite database settings.
- I noticed that running multiple PRAGMA statements in a single query (e.g. `PRAGMA journal_mode=WAL; PRAGMA auto_vacuum=incremental;`) does not work as expected. The settings are not applied. This is why I decided to run each setting in a separate query.

Inspiration
-----------

[](#inspiration)

The general ideas are from Nuno Maduro's package . For more information about possible settings you can look into the SQLite documentation:

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Dimitri König](https://github.com/dimitri-koenig)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance93

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~407 days

Total

2

Last Release

37d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4375825?v=4)[Dimitri König](/maintainers/dimitri-koenig)[@dimitri-koenig](https://github.com/dimitri-koenig)

---

Top Contributors

[![dimitri-koenig](https://avatars.githubusercontent.com/u/4375825?v=4)](https://github.com/dimitri-koenig "dimitri-koenig (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

laravelperformancephpsqlitelaravellaravel-optimize-sqlitedevjoy.ch

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/swiss-devjoy-laravel-optimize-sqlite/health.svg)

```
[![Health](https://phpackages.com/badges/swiss-devjoy-laravel-optimize-sqlite/health.svg)](https://phpackages.com/packages/swiss-devjoy-laravel-optimize-sqlite)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213420.1k2](/packages/wnx-laravel-backup-restore)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
