定制 spaceemotion/php-coding-standard 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

spaceemotion/php-coding-standard

Composer 安装命令:

composer require spaceemotion/php-coding-standard

包简介

Combines multiple code quality tools into one binary with unified output.

README 文档

README

Latest Version on Packagist Total Downloads

php-coding-standard (phpcstd)

diagram of the project workflow

phpcstd combines various code quality tools (e.g. linting and static analysis) into one, easy to use package which can be shared across teams and code bases.

There are two parts to this:

  1. phpcstd executes all the enabled tools and returns a single per-file error output
  2. In your projects, you depend on a single repository (e.g. acme/coding-standard) which depends on phpcstd and includes the various base configurations (e.g. phpmd.xml, ecs.yaml, ...). Your own projects then depend on your own coding standard.

phpcstd itself does not come with any tools preinstalled. You can take a look at my own coding standards as an example.

Tools supported

Tool Lint Fix Source list Description
EasyCodingStandard Combination of PHP_CodeSniffer and PHP-CS-Fixer
PHP Mess Detector Code complexity checker
PHP_CodeSniffer Style linter + fixer
composer-normalize Validates and rearranges composer.json files
phan Static analyzer, requires the "php-ast" extension
php-parallel-lint Checks for PHP (syntax) errors (using php -l)
phpstan Static analyzer, source list is optional, but not recommended
psalm Static analyzer
rector Code up-/downgrading and refactoring tool
deptrac Static analyzer that enforces rules for dependencies between software layers

⭐ = recommended

Getting started

composer require-dev spaceemotion/php-coding-standard 

This will install the phpcstd binary to your vendor folder.

Configuration via .phpcstd(.dist).ini

To minimize dependencies, phpcstd uses .ini-files for its configuration. If no .phpcstd.ini file can be found in your project folder, a .phpcstd.dist.ini file will be used as fallback (if possible).

Command options

Usage: run [options] [--] [<files>...] Arguments: files List of files to parse instead of the configured sources Options: -s, --skip=SKIP Disables the list of tools during the run (comma-separated list) (multiple values allowed) -o, --only=ONLY Only executes the list of tools during the run (comma-separated list) (multiple values allowed) --continue Run the next check even if the previous one failed --fix Try to fix any linting errors --hide-source Hides the "source" lines from console output --lint-staged Uses "git diff" to determine staged files to lint --ci Changes the output format to GithubActions for better CI integration --no-fail Only returns with exit code 0, regardless of any errors/warnings -h, --help Display help for the given command. When no command is given display help for the run command -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug 

Instead of defining the files/folders directly (in either the config or as arguments), you can also pipe a list into it:

$ ls -A1 | vendor/bin/phpcstd 

Git Hooks

To not have to wait for CI pipelines to finish, you can use git hooks to run over the changed files before committing.

vendor/bin/phpcstd --lint-staged

CI-Support

Github Actions

The --ci flag returns a format that can be used by GithubActions to annotate commits and PRs (see their documentation on how this works).

example file change with an error

Development

Using Docker

  1. Spin up the container using GITHUB_PERSONAL_ACCESS_TOKEN=<token> docker-compose up -d --build
  2. Run all commands using docker-compose exec php <command here>

Using XDebug

This project uses composer/xdebug-handler to improve performance by disabling xdebug upon startup. To enable XDebug during development you need to set the following env variable: PHPCSTD_ALLOW_XDEBUG=1 (as written in their README).

spaceemotion/php-coding-standard 适用场景与选型建议

spaceemotion/php-coding-standard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 134.5k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 spaceemotion/php-coding-standard 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 134.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 32
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: ISC
  • 更新时间: 2026-01-04