通过 GIT 钩子实现 PHP 格式整理与语法校验
步骤概括
- 【下载phpcbf】到本地目录(下载地址见文档底部) > 例如: > Linux: ~/.composer/vendor/bin/phpcbf > Windows: c:\space\soft\system\phpcbf.phar
- 【创建hooks】或修改hooks文件:.git/hooks/pre-commit
- 【复制下方脚本】到pre-commit
- 【修改路径】代码中phpcbf和php
Windows环境注意:
Windows环境注意:
其它时间日期代码:
当提示
hint: The '.git/hooks/pre-commit' hook was ignored because it's not set as executable.
hint: You can disable this warning with `git config advice.ignoredHook false`.
是因为钩子文件没有运行权限,根据情况赋予钩子文件执行权限即可,例如:
chmod 700 .git/hooks/pre-commit
场景:yaf 中 controller 类不能指定 namespace,导致无法通过 PSR2 规范检测
电脑端非常需要二维码识别,每次遇到二维码都需要找手机解锁,再唤起 app 来识别,实在麻烦。
其实,用截图工具(比如微信的)就能简单的植入一个二维码识别工具。哪怕初期只能打开个网页什么的呢。