From 733c74567d758eb84f05035c56b5a1aa51110018 Mon Sep 17 00:00:00 2001 From: nick Date: Mon, 7 Dec 2020 12:43:15 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=B7=BB=E5=8A=A0=20php=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=A3=8E=E6=A0=BC=E6=A3=80=E6=B5=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 1 + code-style.md | 35 +++++++++++++++++++++++++++++++++++ composer.md | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 code-style.md diff --git a/SUMMARY.md b/SUMMARY.md index e307e50..e15d993 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -47,6 +47,7 @@ ## 其他 * [other](other.md) * [常用配置](used-settings.md) +* [编码风格](code-style.md) ## PHP 依赖工具 * [Composer](composer.md) diff --git a/code-style.md b/code-style.md new file mode 100644 index 0000000..6b484a9 --- /dev/null +++ b/code-style.md @@ -0,0 +1,35 @@ +Git 提交 PHP 代码风格检测配置 + +```json +{ + "require": { + "friendsofphp/php-cs-fixer": "^2.16", + "brainmaestro/composer-git-hooks": "^2.8" + }, + "extra": { + "hooks": { + "pre-commit": [ + "composer check-style" + ], + "post-merge": "composer install" + } + }, + "scripts": { + "post-update-cmd": [ + "cghooks update" + ], + "post-install-cmd": [ + "cghooks add --ignore-lock", + "cghooks update" + ], + "cghooks": "vendor/bin/cghooks", + "check-style": "php-cs-fixer fix --using-cache=no --diff --config=.php_cs --dry-run --ansi", + "fix-style": "php-cs-fixer fix --using-cache=no --config=.php_cs --ansi" + }, + "scripts-descriptions": { + "check-style": "Run style checks (only dry run - no fixing!).", + "fix-style": "Run style checks and fix violations." + } +} + +``` \ No newline at end of file diff --git a/composer.md b/composer.md index 17cf13d..d76ce10 100644 --- a/composer.md +++ b/composer.md @@ -5,6 +5,8 @@ composer list #显示所有命令 composer show #显示所有包信息 +composer info packagename #查看指定包信息 + composer install #在 composer.json 配置中添加依赖库之后运行此命令安装 composer create-project laravel/laravel Laravel --prefer-dist 5.1.* #创建项目