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.0.0(1y ago)85.3k↓50%MITPHPPHP ^8.2CI passing

Since Apr 14Pushed 5mo 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)[ RSS](/packages/swiss-devjoy-laravel-optimize-sqlite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)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

39

—

LowBetter than 86% of packages

Maintenance60

Regular maintenance activity

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/94ba6c20d1e53a2066e9df02d8fe50390629cc344e16531f552c843c32032180?d=identicon)[dimitri-koenig](/maintainers/dimitri-koenig)

---

Top Contributors

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

---

Tags

laravelperformancephpsqlitelaravelSwiss Devjoylaravel-optimize-sqlite

###  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

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

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

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

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