在开发中,我们会有意识的遵行一套规范来保证团队代码的一致性。PSR是我们PHP遵循的共同规范。

在这里,推荐一个代码格式化工具php-cs-fixer,可以一键把代码格式化为PSR-2的标准。如果以下安装链接失效请查看https://github.com/FriendsOfPHP/PHP-CS-Fixer


安装:

    # 在mac或者linux下执行
    curl -L https://cs.symfony.com/download/php-cs-fixer-v2.phar -o php-cs-fixer
    chmod a+x php-cs-fixer
    mv php-cs-fixer /usr/local/bin/php-cs-fixer

 

使用:  

    # 格式化当前目录下代码 
    php-cs-fixer fix .

 

就是那么简单!

参考资料: https://laravel-china.org/topics/547

 
 

相关文章:

  • 2021-12-25
  • 2022-12-23
  • 2021-09-15
  • 2021-08-28
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2021-07-02
  • 2021-07-24
  • 2022-12-23
相关资源
相似解决方案