{"id":27887050,"url":"https://github.com/swiss-devjoy/laravel-optimize-sqlite","last_synced_at":"2025-06-11T02:07:30.593Z","repository":{"id":287898268,"uuid":"966108979","full_name":"swiss-devjoy/laravel-optimize-sqlite","owner":"swiss-devjoy","description":"Optimize your SQLite database for production in Laravel","archived":false,"fork":false,"pushed_at":"2025-04-16T19:36:22.000Z","size":19,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T10:12:27.215Z","etag":null,"topics":["laravel","performance","php","sqlite"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swiss-devjoy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"Swiss Devjoy"}},"created_at":"2025-04-14T12:18:15.000Z","updated_at":"2025-04-25T03:17:32.000Z","dependencies_parsed_at":"2025-04-14T14:58:34.605Z","dependency_job_id":"0fee891e-2477-49a1-8f76-603fa33d7d07","html_url":"https://github.com/swiss-devjoy/laravel-optimize-sqlite","commit_stats":null,"previous_names":["swiss-devjoy/laravel-optimize-sqlite"],"tags_count":1,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Flaravel-optimize-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Flaravel-optimize-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Flaravel-optimize-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Flaravel-optimize-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiss-devjoy","download_url":"https://codeload.github.com/swiss-devjoy/laravel-optimize-sqlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiss-devjoy%2Flaravel-optimize-sqlite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259184744,"owners_count":22818268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","performance","php","sqlite"],"created_at":"2025-05-05T08:01:39.574Z","updated_at":"2025-06-11T02:07:30.332Z","avatar_url":"https://github.com/swiss-devjoy.png","language":"PHP","readme":"# Optimize your SQLite database for production in Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/swiss-devjoy/laravel-optimize-sqlite.svg?style=flat-square)](https://packagist.org/packages/swiss-devjoy/laravel-optimize-sqlite)\n[![Total Downloads](https://img.shields.io/packagist/dt/swiss-devjoy/laravel-optimize-sqlite.svg?style=flat-square)](https://packagist.org/packages/swiss-devjoy/laravel-optimize-sqlite)\n\n\u003e This package is already used in production in multiple projects.\n\u003e Still, if you want to use this package, **always** backup your database before requiring it through Composer.\n\nThis 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.\n\nThe current settings are:\n\n```\n ┌───────────────────────────┬─────────────────────┬\n │ Setting                   │ Value               │\n ├───────────────────────────┼─────────────────────┼\n │ PRAGMA auto_vacuum        │ incremental         │\n │ PRAGMA journal_mode       │ WAL                 │\n │ PRAGMA page_size          │ 32768 (32 KB)       │\n │ PRAGMA busy_timeout       │ 5000 (5 seconds)    │\n │ PRAGMA cache_size         │ -20000              │ \n │ PRAGMA foreign_keys       │ ON                  │\n │ PRAGMA mmap_size          │ 134217728 (128 MB)  │\n │ PRAGMA temp_store         │ MEMORY              │\n │ PRAGMA synchronous        │ NORMAL              │\n └───────────────────────────┴─────────────────────┘\n ```\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require swiss-devjoy/laravel-optimize-sqlite\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"laravel-optimize-sqlite-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    // add, remove or modify SQLite settings to optimize performance. all settings are PRAGMA statements, like \"PRAGMA journal_mode = WAL;\"\n    'general' =\u003e [\n        'journal_mode' =\u003e 'WAL',\n        'auto_vacuum' =\u003e 'incremental',\n        'page_size' =\u003e 32768, // 32 KB\n        'busy_timeout' =\u003e 5000, // 5 seconds\n        'cache_size' =\u003e -20000,\n        'foreign_keys' =\u003e 'ON',\n        'mmap_size' =\u003e 134217728, // 128 MB\n        'temp_store' =\u003e 'MEMORY',\n        'synchronous' =\u003e 'NORMAL',\n    ],\n\n    // You can override the general settings for specific database connections, defined in config/database.php\n    'databases' =\u003e [\n        'example_connection' =\u003e [\n            'busy_timeout' =\u003e 10000, // override general settings and set 10 seconds\n            'temp_store' =\u003e null, // unset temp_store from general settings\n        ],\n    ],\n];\n```\n\nYou can set general settings for all sqlite connections, and override them for specific connections.\nIf you want to remove a general setting, just remove the config line from the config file.\nIf you want to add a new setting, just add it to the config file.\n\n## Important notes\n\n- There is a known issue with databases already in WAL mode and running php artisan migrate:fresh which will throw an error, see https://github.com/laravel/framework/discussions/53044\n  My current alternative is to run a custom composer command (`composer.json`) which refreshes the whole app:\n  ```\n    \"scripts\": {\n        \"dev-migrate\": [\n            \"Composer\\\\Config::disableProcessTimeout\",\n            \"rm -f database/*.sqlite\",\n            \"touch database/database.sqlite\",\n            \"@php artisan migrate --seed --ansi\",\n            \"@php artisan cache:clear\"\n        ]\n    },\n  ```\n- 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.\n- 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.\n\n## Inspiration\n\nThe general ideas are from Nuno Maduro's package https://github.com/nunomaduro/laravel-optimize-database.\nFor more information about possible settings you can look into the SQLite documentation: https://www.sqlite.org/pragma.html\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Dimitri König](https://github.com/dimitri-koenig)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":["https://github.com/sponsors/Swiss Devjoy"],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiss-devjoy%2Flaravel-optimize-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiss-devjoy%2Flaravel-optimize-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiss-devjoy%2Flaravel-optimize-sqlite/lists"}