承接 eonx-com/easy-quality 相关项目开发

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

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

eonx-com/easy-quality

Composer 安装命令:

composer require eonx-com/easy-quality

包简介

Makes using of code quality tools for PHP projects of EonX easier

README 文档

README

---eonx_docs--- title: Introduction weight: 0 ---eonx_docs---

This package is a way to centralise reusable classes used for coding standards and quality tools. It contains:


Install (separately from the project's composer.json file)

  1. Create a quality directory in your project root.

  2. Go to the quality directory and run composer require eonx-com/easy-quality.

  3. Set env variables to speed up local execution:

    • EONX_EASY_QUALITY_JOB_SIZE - number of files to process in parallel (default: 2)
    • EONX_EASY_QUALITY_MAX_NUMBER_OF_PROCESS - maximum number of parallel processes (default: 4)
    • EONX_EASY_QUALITY_TIMEOUT_SECONDS - timeout in seconds for each process (default: 120)
  4. Add quality/vendor to Git ignore (either in a .gitignore file inside the quality directory or in you project's root .gitignore file).

  5. Update your project's composer.json file by adding a post-install script (this will automate an installation of eonx-com/easy-quality on all the local machines):

    {
        "post-install-cmd": [
            "cd quality && composer install --no-dev"
        ]
    }
  6. Update your project's composer.json file by adding the following scripts. Here we use veewee/composer-run-parallel (install it as a dev dependency) for the check-all script to run multiple commands in parallel. Feel free to modiy these commands as you wish.

    {
        "scripts": {
            "check-all": "@parallel check-security check-ecs check-rector check-phpmd-app check-phpmd-tests check-phpstan",
            "check-ecs": "php -d memory_limit=1024M quality/vendor/bin/ecs check --clear-cache",
            "check-phpmd-app": "quality/vendor/bin/phpmd src ansi phpmd.app.xml",
            "check-phpmd-tests": "quality/vendor/bin/phpmd tests ansi phpmd.tests.xml",
            "check-phpstan": "quality/vendor/bin/phpstan analyse --ansi --memory-limit=1000M",
            "check-rector": "quality/vendor/bin/rector process --dry-run"
        }
    }
  7. Make sure you have config files for ECS, Rector, PHP Mess Detector, and PHPStan in the project source code root.

  8. Run composer check-all from the project source code root to make sure everything is working and fix the found issues.

  9. If you want to use the quality tools in CI, here is an example of a GitHub action configuration:

        coding-standards:
            needs: composer
            runs-on: ubuntu-latest
            timeout-minutes: 60
            strategy:
                fail-fast: false
                matrix:
                    php: ['8.2']
                    actions:
                        - {name: phpstan, run: composer check-phpstan}
                        - {name: phpmd-app, run: composer check-phpmd-app}
                        - {name: phpmd-tests, run: composer check-phpmd-tests}
                        - {name: rector, run: composer check-rector}
                        - {name: security, run: composer check-security}
                        - {name: yaml-linter, run: './bin/console lint:yaml config src translations --parse-tags'}
                        - {name: ecs, run: composer check-ecs}
            env:
                EONX_EASY_QUALITY_JOB_SIZE: 20
                EONX_EASY_QUALITY_MAX_NUMBER_OF_PROCESS: 32
                EONX_EASY_QUALITY_TIMEOUT_SECONDS: 120
    
            name: ${{ matrix.actions.name}} (${{ matrix.php }})
    
            steps:
                -
                    uses: actions/checkout@v4
    
                -
                    uses: shivammathur/setup-php@v2
                    with:
                        php-version: ${{ matrix.php }}
                        coverage: none
    
                -
                    name: Get the cached Composer dependencies
                    uses: actions/cache@v4
                    with:
                        path: src/vendor
                        key: composer-${{ hashFiles('src/composer.lock') }}
    
                -
                    name: Get the cached quality tools installation
                    id: cache-quality-tools
                    uses: actions/cache@v4
                    with:
                        path: quality/vendor
                        key: quality-tools-composer-${{ hashFiles('quality/composer.lock') }}
    
                -
                    name: Install quality tools
                    if: steps.cache-quality-tools.outputs.cache-hit == false
                    run: composer --working-dir=../quality install --prefer-dist --no-scripts --no-progress --no-interaction --no-dev
    
                -
                    name: Check ${{ matrix.actions.name }}
                    run: ${{ matrix.actions.run }}
                    shell: bash

Prepare configuration file for ECS (Easy Coding Standard) Sniffs

Create a configuration file for ECS in the quality folder of the project.

For example see quality/ecs.php.

Run ECS check

Go to the root folder of the project and run

composer check-ecs

or

quality/vendor/bin/ecs check

Expected output:

[OK] No errors found. Great job - your code is shiny in style!

Prepare configuration file for Rector

Create a configuration file for Rector in the quality folder of the project.

For example see quality/rector.php.

Run Rector check

Go to the root folder of the project and run

composer check-rector

or

quality/vendor/bin/rector process --dry-run

Expected output:

[OK] Rector is done!

Using phpmetrics checker

Run

quality/vendor/eonx-com/easy-quality/bin/pmc.phar --config=quality/pmc.json

An example of pmc.json config file:

{
    "paths": [
        "../src/src"
    ],
    "metrics": {
        "efferentCoupling": {
            "skip": [
                "App\\Entity\\SomeEntity",
                "App\\*\\ApiResource\\*",
                "*Dto"
            ],
            "maxValue": 14
        },
        "cyclomaticComplexity": {
            "skip": [
                "App\\Service\\*"
            ],
            "maxValue": 10
        },
    }
}

eonx-com/easy-quality 适用场景与选型建议

eonx-com/easy-quality 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 892.17k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2021 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 eonx-com/easy-quality 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 892.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 13
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-04