ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## 代码规范 ### 遵循标准: [php-fig标准](http://www.php-fig.org/psr/psr-4/) [PHP编码规范(中文版)](http://www.kancloud.cn/thinkphp/php-fig-psr) [REST API 安全设计指南](http://www.kancloud.cn/kancloud/rest-api-design-safety) [Web开发规范文档](http://www.kancloud.cn/chandler/css-code-guide) [PHP之道(中文版)](http://www.kancloud.cn/thinkphp/php-the-right-way) [PHP 开发规范](http://www.kancloud.cn/itsky71/php-standard) [PHP设计模式简介](http://larabase.com/collection/5/post/143) [PHP 之道 | PHP The Right Way 中文版](http://laravel-china.github.io/php-the-right-way/) [首页 | TIPI: 深入理解PHP内核](http://php-internals.com/) [Zephir Programming Language](https://zephir-lang.com/) [CoffeePHP社区 - Powered by PHPHub](http://coffeephp.com/) 函数命名,类命名,文件名,目录名等等 * 本项目代码格式化标准选用 [**PSR-2**](http://www.kancloud.cn/thinkphp/php-fig-psr/3141); * 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144); * * * * * ### 关于Unix哲学 [关于Unix哲学](http://www.ruanyifeng.com/blog/2009/06/unix_philosophy.html) >[danger] KEEP IT SIMPLE , STUPID ! (保持简单,保持愚蠢。) >[info] 一个程序只做一件事,并且做好,简单即是最好。 * * * * * ### 编码规范: 规定团队设置编辑器为UTF-8(无BOM)编码,否则团队编码不统一,使用github时出问题。或者难以管理,导致出现各种隐含的BUG。 使用空格缩进,tab为四个空格。参考:[sublime text3中tab怎么设置为默认缩进四个空格](https://zhidao.baidu.com/question/1672622739142258907.html) 最好有代码审查工具。 注释规范: [“/\*\*/”与“/\*\*\*/”的区别](http://zhidao.baidu.com/link?url=qryCwVHuV5hMmvUSWS74iOmvrEcpdIxSSF6S6jJIv29qRyNdwXwFHQtjvf1mYBaBUETjrd5q4p4seWKC0IEUjq) [javadoc自动生成开发文档](http://blog.csdn.net/cxxxxc/article/details/4307116) * * * * * [4位神级大牛说“别神化程序员了,编程不需要天赋和激情!”_网易订阅](http://dy.163.com/wemedia/article/detail/BQD2SG720511831M.html) One man s crappy software is another man s full time job.(Jessica Gaston) 一个人写的烂软件将会给另一个人带来一份全职工作。 Any fool can write code that a computer can understand. Good programmers write code that humans can understand. 傻瓜写计算机能理解的代码。优秀的程序员写人类能读懂的代码。 Software and cathedrals are much the same — first we build them, then we pray.(Sam Redwine) 软件和教堂非常相似——首先,我们建造它们,然后我们祈祷。(Sam Redwine) * * * * * ### 开发环境 为了在开发环境中显示所有可能的错误,将你的 php.ini 进行如下配置: ```ini display_errors = On display_startup_errors = On error_reporting = -1 log_errors = On ``` * * * * * ### 生产环境 为了在生产环境中隐藏错误显示,将你的 php.ini 进行如下配置: ```ini display_errors = Off display_startup_errors = Off error_reporting = E_ALL log_errors = On ``` [PHP之道 - 错误报告](http://www.kancloud.cn/thinkphp/php-the-right-way/3192) * * * * * ### 命名规范 函数/方法/变量 命名规范:动词+名词+形容词 比如:addProducts() * * * * * ### 返回码规范 最好在一套系统中,甚至一个团队,一个公司中都遵循一套返回状态码规则,并提前做好规划,比如: 0001 ~ 1999 ,2000 ~ 2999,4000 ~ 4999 这些码段可以按:业务类型,按功类型,按架构层面提前规划好,比如x~y是网络段的,哪段用于错误码,哪段用于成功码,感觉这样从架构层面上来分比较清晰,一下子就知道是成功还是失败了,然后根据其它位上的数还可以识别出业务层上面的特征,感觉这几种规划组合起来有最好的效果,给出码段。这样整体规划就能达到统一了。 ABCD四位 A:? B:? C:? D:? last update:2017-10-11 01:03:03