PHPackages                             nunomaduro/laravel-optimize-database - 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. nunomaduro/laravel-optimize-database

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

nunomaduro/laravel-optimize-database
====================================

Publishes migrations that make your database production ready.

v1.0.5(1y ago)26123.0k↓13.1%9[6 issues](https://github.com/nunomaduro/laravel-optimize-database/issues)MITPHPPHP ^8.2.0

Since Jul 25Pushed 1y ago5 watchersCompare

[ Source](https://github.com/nunomaduro/laravel-optimize-database)[ Packagist](https://packagist.org/packages/nunomaduro/laravel-optimize-database)[ Fund](https://www.paypal.com/paypalme/enunomaduro)[ GitHub Sponsors](https://github.com/nunomaduro)[ RSS](/packages/nunomaduro-laravel-optimize-database/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (7)Used By (0)

 [![Skeleton Php](https://raw.githubusercontent.com/nunomaduro/laravel-optimize-database/main/docs/logo.png)](https://raw.githubusercontent.com/nunomaduro/laravel-optimize-database/main/docs/logo.png)

 [![GitHub Workflow Status (main)](https://github.com/nunomaduro/laravel-optimize-database/actions/workflows/tests.yml/badge.svg)](https://github.com/nunomaduro/laravel-optimize-database/actions) [![Total Downloads](https://camo.githubusercontent.com/14ee1756033daf9439c950b032a2c32bf638dc7bcdf7f38fd342d64df42d3754/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e756e6f6d616475726f2f6c61726176656c2d6f7074696d697a652d6461746162617365)](https://packagist.org/packages/nunomaduro/laravel-optimize-database) [![Latest Version](https://camo.githubusercontent.com/1c63ac2c0d94a890550279f76d6a4ce5342d4f8b8ce922a5b7e81ed2be6a3daf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e756e6f6d616475726f2f6c61726176656c2d6f7074696d697a652d6461746162617365)](https://packagist.org/packages/nunomaduro/laravel-optimize-database) [![License](https://camo.githubusercontent.com/e1ed96d8f3e065daae0e333fdf1357a7e05bb398c0c3caef63b76ce0863da5f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e756e6f6d616475726f2f6c61726176656c2d6f7074696d697a652d6461746162617365)](https://packagist.org/packages/nunomaduro/laravel-optimize-database)

---

> This package is a **work-in-progress**, therefore you should not use it in production - and **always** backup your database before requiring it through Composer.

This package provides a simple way to optimize your SQLite database in Laravel; it's a good starting point for production-ready SQLite databases. At the time of this writing, it applies the following settings:

```
 ┌───────────────────────────┬─────────────┬───────────┐
 │ Setting                   │ Value       │ Via       │
 ├───────────────────────────┼─────────────┼───────────┤
 │ PRAGMA auto_vacuum        │ incremental │ Migration │
 │ PRAGMA journal_mode       │ WAL         │ Migration │
 │ PRAGMA page_size          │ 32768       │ Migration │
 │ PRAGMA busy_timeout       │ 5000        │ Runtime   │
 │ PRAGMA cache_size         │ -20000      │ Runtime   │
 │ PRAGMA foreign_keys       │ ON          │ Runtime   │
 │ PRAGMA incremental_vacuum │ (enabled)   │ Runtime   │
 │ PRAGMA mmap_size          │ 2147483648  │ Runtime   │
 │ PRAGMA temp_store         │ MEMORY      │ Runtime   │
 │ PRAGMA synchronous        │ NORMAL      │ Runtime   │
 └───────────────────────────┴─────────────┴───────────┘

```

The settings are applied in two ways:

- **[Migration Stub](https://github.com/nunomaduro/laravel-optimize-database/blob/main/database/migrations/optimize_database_settings.php.stub)** - Applied via migration.
- **[Runtime Configuration](https://github.com/nunomaduro/laravel-optimize-database/blob/main/src/LaravelOptimizeDatabaseServiceProvider.php)** - Applied at runtime, via service provider.

🚀 Installation
--------------

[](#-installation)

> **Requires [PHP 8.2+](https://php.net/releases), [SQLite 3.46+](https://www.sqlite.org/changes.html) and [Laravel 11.0+](https://laravel.com)**

You can install the package via [Composer](https://getcomposer.org):

```
composer require nunomaduro/laravel-optimize-database
```

🙌 Usage
-------

[](#-usage)

To get started optimizing your SQLite database, you need to run the following command:

```
php artisan db:optimize
```

At this point, the \[Runtime\] settings are applied automatically. However, you need to run the migration to apply the \[Migration\] settings:

```
php artisan migrate
```

**Laravel Optimize Database** was created by **[Nuno Maduro](https://twitter.com/enunomaduro)** under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.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 ~0 days

Total

6

Last Release

661d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86cfef5c1f5195df1a9db17a5f8ecb34455e1f0133a725de9acf7f2fb26ac6a1?d=identicon)[nunomaduro](/maintainers/nunomaduro)

---

Top Contributors

[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (25 commits)")[![dxnter](https://avatars.githubusercontent.com/u/17434202?v=4)](https://github.com/dxnter "dxnter (1 commits)")[![panda-madness](https://avatars.githubusercontent.com/u/6180087?v=4)](https://github.com/panda-madness "panda-madness (1 commits)")[![veeqtoh](https://avatars.githubusercontent.com/u/19429315?v=4)](https://github.com/veeqtoh "veeqtoh (1 commits)")

---

Tags

databaselaravelphpsqlitelaraveldatabasemigrationsoptimization

###  Code Quality

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nunomaduro-laravel-optimize-database/health.svg)

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

###  Alternatives

[nwidart/db-exporter

Export your database quickly and easily as a Laravel Migration and all the data as a Seeder class.

37839.1k](/packages/nwidart-db-exporter)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3426.7k](/packages/orptech-laravel-migration-partition)[sarfraznawaz2005/indexer

Laravel package to monitor SELECT queries and offer best possible INDEX fields.

562.7k](/packages/sarfraznawaz2005-indexer)

PHPackages © 2026

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