承接 swiss-devjoy/laravel-optimize-sqlite 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

swiss-devjoy/laravel-optimize-sqlite

Composer 安装命令:

composer require swiss-devjoy/laravel-optimize-sqlite

包简介

Optimize your SQLite database for production in Laravel

README 文档

README

Latest Version on Packagist Total Downloads

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

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

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

The general ideas are from Nuno Maduro's package https://github.com/nunomaduro/laravel-optimize-database. For more information about possible settings you can look into the SQLite documentation: https://www.sqlite.org/pragma.html

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

swiss-devjoy/laravel-optimize-sqlite 适用场景与选型建议

swiss-devjoy/laravel-optimize-sqlite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.28k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2025 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「laravel-optimize-sqlite」 「devjoy.ch」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 swiss-devjoy/laravel-optimize-sqlite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 swiss-devjoy/laravel-optimize-sqlite 我们能提供哪些服务?
定制开发 / 二次开发

基于 swiss-devjoy/laravel-optimize-sqlite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-14