PHPackages                             giles/php-csc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. giles/php-csc

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

giles/php-csc
=============

PHP code style check 利用git hook、phplint、phpcs在git commit的时候对php代码进行语法检测、代码风格检查，如果有问题，不允许提交。

v0.2.0(2y ago)02551MITPHPPHP &gt;=7.1CI failing

Since Aug 29Pushed 2y agoCompare

[ Source](https://github.com/RookieGiles/code-style-psr)[ Packagist](https://packagist.org/packages/giles/php-csc)[ RSS](/packages/giles-php-csc/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (3)Versions (5)Used By (0)

介绍
==

[](#介绍)

PHP code style check 利用git hook、phplint、phpcs在git commit的时候对php代码进行语法检测、代码风格检查，如果有问题，不允许提交。

前置要求
====

[](#前置要求)

- Git已安装
- PHP安装并全局可用 Windows下载最新版php [php-7.3.8-nts-Win32-VC15-x64.zip](https://windows.php.net/downloads/releases/php-7.3.8-nts-Win32-VC15-x64.zip)
- Composer可用 [Windows下载 Composer](https://getcomposer.org/Composer-Setup.exe)

检测原理 及流程
--------

[](#检测原理-及流程)

- 每次git commit前是有hooks可以触发
- 开发特定脚本,在git hooks触发的时候执行
- 首先利用phpline检测提交文件的语法是否有错
- 再次利用phpcs检测php的风格规范是否是否符合特定的规范
- 符合规范 可以继续执行git push
- 不符合规范，本次commit失败，需要根据错误提示更改
- 再次 git add &amp;&amp; git commit

使用
==

[](#使用)

composer require --dev giles/php-csc

该命令会根据本机系统检查phplint、phpcs的安装情况，并将git原有的pre-commit钩子备份， 再将php-csc的pre-commit钩子拷贝至.git/hooks中。

这样，在git commit之前，就会执行phplint和phpcs检查待提交的文件，如果不满足要求，则会阻止代码提交。

开放指令
====

[](#开放指令)

指令 (composer exec -v phpcsc {指令}用法install安装php-cscremove移除php-csccomposer 自动挂载
=============

[](#composer-自动挂载)

在主项目composer 文件中增加事件

```
"post-autoload-dump": [
    "Giles\\MountHooks\\PHPCodeChecker::hookInstall"
],
"pre-package-uninstall": [
    "Giles\\MountHooks\\PHPCodeChecker::hookUnstall"
]
```

可以在没次执行composer update 的时候去检测钩子挂载情况,自动挂载钩子

注意事项
====

[](#注意事项)

- phpcsc的pre-commit会覆盖原有的pre-commit，但仍然会将它备份为pre-commit.bak.{timestamp}。所以之前有在pre-commit中插入操作，请谨慎安装。
- Windows版本的PHPStorm 默认回车符\\r\\n 这是不符合PSR2 规范的 需要设置为\\n `File->Line Separators->LF - Unix and macOs (\n)`

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~557 days

Total

4

Last Release

783d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfc850ee019cd0508bea0a5c543810eac193d4aecade4d40a8a0eb2ff5039bb5?d=identicon)[Giles](/maintainers/Giles)

---

Top Contributors

[![giles9028](https://avatars.githubusercontent.com/u/56870153?v=4)](https://github.com/giles9028 "giles9028 (1 commits)")

---

Tags

psrphpcsPSR-11phpcsc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/giles-php-csc/health.svg)

```
[![Health](https://phpackages.com/badges/giles-php-csc/health.svg)](https://phpackages.com/packages/giles-php-csc)
```

###  Alternatives

[psr/container

Common Container Interface (PHP FIG PSR-11)

10.0k1.0B3.7k](/packages/psr-container)[mayflower/mo4-coding-standard

PHP CodeSniffer ruleset implementing the MO4 coding standards extending the Symfony coding standards.

17508.3k5](/packages/mayflower-mo4-coding-standard)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.1M29](/packages/yoast-yoastcs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
