步骤概括

  • 【下载phpcbf】到本地目录(下载地址见文档底部)

> 例如:
> Linux: ~/.composer/vendor/bin/phpcbf
> Windows: c:spacesoftsystemphpcbf.phar

  • 【创建hooks】或修改hooks文件:.git/hooks/pre-commit
  • 【复制下方脚本】到pre-commit
  • 【修改路径】代码中phpcbf和php

    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