the-provost/laravel-summdb 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

the-provost/laravel-summdb

Composer 安装命令:

composer require the-provost/laravel-summdb

包简介

A tool to summarize Laravel database structure from migration files

README 文档

README

This tool analyzes Laravel migration files and generates a summary of the database structure, including an Entity-Relationship Diagram (ERD) using Mermaid.js syntax.

License GitHub stars GitHub tag

NPM

npm version NPM Downloads

COMPOSER

Packagist Version Composer Downloads

Package Name

The name of the package on the github repo is a portmanteau of 'Summed Up' to denote a summing up of the DB of the app.

The npm package name however is a clear and understandable 'laravel-db-summary'.

Installation

NPM:

You can install Laravel DB Summarizer globally using npm:

npm install -g laravel-db-summary

Or use it directly with npx:

npx laravel-db-summary

COMPOSER:

You can install the package via Composer:

composer require the-provost/laravel-summdb

Usage

NPM:

There are two ways to use Laravel DB Summarizer:

  1. Interactive Mode: Run the tool without any arguments, and it will prompt you for the Laravel project path:
laravel-db-summary
  1. Command Line Mode: Provide the path to your Laravel project as an argument:
laravel-db-summary /path/to/your/laravel/project

COMPOSER

After installation, you can use the Laravel SummDB command:

php artisan db:summarize

This command will analyze your Laravel migration files and generate a summary.

Output

The script generates three files in a 'db-summary' directory:

  1. text-summary.txt: A text summary of each table, its columns, and foreign key relationships.
  2. erd.mmd: Mermaid.js ERD code that can be visualized using tools like the Mermaid Live Editor.
  3. erd.png: A PNG image of the Entity-Relationship Diagram (requires Mermaid CLI to be installed).

If you don't have Mermaid CLI installed, you can still use the erd.mmd file to generate the diagram online.

Requirements

  • Node.js (version 12.0.0 or higher)
  • A Laravel project with migration files

Documentation

For detailed documentation, please refer to:

  • npm Package README
  • Composer Package README

Development

To contribute or modify the tool:

  • Clone the repository:
git clone https://github.com/the-provost/laravel-summdb.git

Navigate to the desired package directory (js/ or php/) and follow the development instructions in the respective README.

Configuration

COMPOSER:

You can publish the configuration file with:

php artisan vendor:publish --provider="TheProvost\LaravelSummDB\LaravelSummDBServiceProvider" --tag="config"

This will publish a laravel-summdb.php file in your config directory.

Integrating with CI/CD Pipeline

NPM:

To include Laravel DB Summarizer as part of your CI/CD pipeline, follow these steps:

  1. Install Laravel DB Summarizer in your CI environment: Add this to your CI configuration file (e.g., .gitlab-ci.yml, .github/workflows/main.yml):

    - js install -g laravel-db-summary
  2. Run Laravel DB Summarizer: Add a step in your CI pipeline to run the tool:

    - laravel-db-summary /path/to/your/laravel/project
  3. Archive the generated files: Configure your CI to archive the db-summary directory as an artifact. For example, in GitLab CI:

    artifacts:
      paths:
        - db-summary/
  4. Optional: Generate PNG in CI: If you want to generate the PNG in your CI pipeline, ensure Mermaid CLI is installed:

    - js install -g @mermaid-js/mermaid-cli
  5. Example GitLab CI configuration:

    stages:
      - build
      - test
      - document
    
    document_db:
      stage: document
      script:
        - js install -g laravel-db-summary @mermaid-js/mermaid-cli
        - laravel-db-summary .
      artifacts:
        paths:
          - db-summary/
  6. Example GitHub Actions workflow:

    name: Document Database
    on: [push]
    jobs:
      document:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v2
        - name: Use Node.js
          uses: actions/setup-node@v2
          with:
            node-version: '14'
        - run: js install -g laravel-db-summary @mermaid-js/mermaid-cli
        - run: laravel-db-summary .
        - uses: actions/upload-artifact@v2
          with:
            name: db-summary
            path: db-summary/

COMPOSER:

To include Laravel SummDB as part of your Laravel CI/CD pipeline, you can add the command to your build process. For example, in GitLab CI:

stages:
  - build
  - test
  - document

document_db:
  stage: document
  script:
    - php artisan db:summarize
  artifacts:
    paths:
      - db-summary/

By following these steps, you'll ensure that every build of your Laravel application includes an up-to-date database summary and ERD.

Note

This script parses migration files statically and may not capture all complex scenarios or dynamic schema modifications. It's designed as a quick summary tool and may not reflect the exact state of a database that has undergone manual modifications or complex migrations.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

If you find a bug or have a suggestion, please file an issue on the GitHub repository.

Credits

Laravel SummDB makes use of the following open-source packages:

the-provost/laravel-summdb 适用场景与选型建议

the-provost/laravel-summdb 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 1.89k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 the-provost/laravel-summdb 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.89k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-23