承接 jpswade/laravel-database-tools 相关项目开发

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

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

jpswade/laravel-database-tools

Composer 安装命令:

composer require jpswade/laravel-database-tools

包简介

Laravel Database Tools

README 文档

README

Tests

The "missing" database toolset for Laravel. A set of commonly used Database Tools for Laravel.

Tested against Laravel 10-13 on PHP 8.1-8.4.

With this package you can:

  • Create a database (if it does not exist)
  • Dump from another database to file
  • Get and unzip from a database backup created by the Spatie Backup package
  • Import from file
  • Update the charset and collation
  • Fixes the "no such function" error by giving SQLite MySQL compatibility by creating the missing function using PDO for SQLite using PHP functions.
  • Uses MySQL commands to optimize database tables (using OPTIMIZE TABLE)

Install

Install the package into your Laravel application:

  • composer require --dev jpswade/laravel-database-tools

Note: It's wise to only install these tools in development by default, as it's rare you should need them in a production environment.

Configure

Publish and customise your own dbtools.php file:

  • php artisan vendor:publish --provider="Jpswade\LaravelDatabaseTools\ServiceProvider" --tag="config"

This allows you to set the source database and/or filesystem for the backup.

  • dbtools.database - Define the source database for the db:dump command, similar to Laravel databases config.
  • dbtools.filesystem - Define the source filesystem for the db:getFromBackup command, similar to Laravel filesystems config.
  • dbtools.filesystem.path - Define the path for the db:getFromBackup command.
  • dbtools.import - Here you can define the method (command or normal) for the db:importFromFile command.

Note:

  • The db:getFromBackup command falls back to the spatie/laravel-backup package for configuration.

Usage

The commands are:

  • db:create - Creates the database schema.
  • db:dump - Fetch a copy of the latest database from the configured server.
  • db:getFromBackup - Download database backup file from backup.
  • db:importFromFile {file?} - Import data from a sql file into a database.
  • db:charset - Changes the charset and collation to whatever the database is set to use.
  • db:optimize - Optimizes your database tables.

SQLite MySQL Compatability Provider

For testing you can add the provider to your Test:

    protected function registerServiceProviders(): void
    {
        $this->app->register(SqliteMysqlCompatibilityProvider::class);
    }

    protected function setUp(): void
    {
        parent::setUp();

        $this->registerServiceProviders();
    }

In production, follow the usual Registering Providers instructions:

In config/app.php, find the providers array and add:

'providers' => [
    // Other Service Providers
 
    Jpswade\LaravelDatabaseTools\SqliteMysqlCompatibilityProvider::class,
],

Limitations

These are limitations you'll come across if you use certain commands:

  • The db:getFromBackup command relies on the league/flysystem-aws-s3-v3 "^1.0" package, when you use the Amazon S3 Driver as per the Laravel docs.
  • The db:dump command depends on spatie/db-dumper.
  • The commands have only been tested to work with MySQL at the moment, but could be extended to others.
  • The db:importFromFile command can only import .sql files.
  • The db:optimize command only works with MySQL (at the moment).

Contributing

The package ships an opinionated dev-tooling stack alongside the test suite:

  • composer pint - applies Laravel Pint formatting (Laravel preset + declare_strict_types, strict_comparison, is_null, modernize_types_casting). Config lives in pint.json.
  • composer pint-test - the read-only equivalent used by CI; fails if anything needs reformatting.
  • composer phpunit - test suite (Testbench + PHPUnit).
  • composer phpstan - static analysis at Larastan level 6 with phpstan-strict-rules; pre-existing issues are captured in phpstan-baseline.neon.
  • composer test - runs Pint (test mode), PHPStan, then PHPUnit.

This package also installs Laravel Boost and jpswade/laravel-best-practices as dev dependencies for AI-assisted development. The committed boost.json opts contributors into the relevant skills for Cursor, Claude Code, and Codex; run php artisan boost:install --no-interaction after composer install to materialise those skills into your editor's agent directory. Contributors using a different editor can override locally - boost.json is the maintainer default, not a hard requirement.

CI runs the test suite across the full PHP x Laravel matrix on every push and pull request - see .github/workflows/tests.yml.

Troubleshooting

Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found

% composer require league/flysystem-aws-s3-v3:~1.0

Note: Needed for db:getFromBackup command to use the S3 Driver.

Class "League\Flysystem\AwsS3V3\PortableVisibilityConverter" not found

% composer require league/flysystem-aws-s3-v3

Class 'Spatie\DbDumper\Databases\MySql' not found

% composer require spatie/db-dumper

Note: Needed by the db:dump command.

jpswade/laravel-database-tools 适用场景与选型建议

jpswade/laravel-database-tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.26k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 01 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 jpswade/laravel-database-tools 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 10.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-17