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.* #创建项目