开发时遵循PSR-2命名规范和PSR-4自动加载规范,并且注意如下规范:
* * * * *
[TOC]
* * * * *
### 目录和文件
#### 目录
使用小写+下划线;
#### 类库、函数文件后缀
统一以.php为后缀;
#### 类的文件名
均以命名空间定义,并且命名空间的路径和类库文件所在路径一致;
类文件采用驼峰法命名(首字母大写),其它文件采用小写+下划线命名;
类名和类文件名保持一致,统一采用驼峰法命名(首字母大写);
### 函数和类、属性命名
#### 类的命名
采用驼峰法(首字母大写),例如 User、UserType,默认不需要添加后缀,例如UserController应该直接命名为User;
#### 函数的命名
使用小写字母和下划线(小写字母开头)的方式,例如 get_client_ip;
####方法的命名
使用驼峰法(首字母小写),例如 getUserName;
####属性的命名
使用驼峰法(首字母小写),例如 tableName、instance;
以双下划线“__”打头的函数或方法作为魔法方法,例如 __call 和 __autoload;
### 常量和配置
#### 常量
以大写字母和下划线命名,例如 APP_PATH和 THINK_PATH;
#### 配置参数
以小写字母和下划线命名,例如 url_route_on 和url_convert;
### 数据表和字段
#### 数据表
采用小写加下划线方式命名,并注意字段名不要以下划线开头,例如 think_user 表和 user_name字段,不建议使用驼峰和中文作为数据表字段命名。
#### 字段
采用小写加下划线方式命名,并注意字段名不要以下划线开头,例如 think_user 表和 user_name字段,不建议使用驼峰和中文作为数据表字段命名。
### 模型命名规则
#### BaseModel
直接命名 Base
#### TableBaseModel
直接命名 Table
#### TableFuncModel
命名为 TableFunc
### 应用类库命名空间规范
应用类库的根命名空间统一为app(可以设置app_namespace配置参数更改);
例如:app\index\controller\Index和app\index\model\User。