开发工具
简介
本文档的主要说明开发过程中涉及的一些工具的初始化配置,目的是为了统一项目风格、方便同事之间的代码调试,从而提高团队协作及工作效率。
非特殊情况下团队内部应使用相同的开发工具,包括且不限于以下方面:
- IDE工具
- 开发环境(PHP、MySQL、Apache、Redis等)
- 版本管理工具
- 命令行工具
通用规范
以下规范适用于所有工具:
- 文件编码统一为
utf-8
- 文件内容统一去掉尾部
空格
- 文件内容换行符统一为
LF
工具版本
团队内部统一
工具配置
Sublime Text
{
"tab_size": 4, // Tab占位大小
"default_encoding": "UTF-8", // 默认编码
"default_line_ending": "unix", // 换行符
"translate_tabs_to_spaces": true, // 是否将Tab转换为空格
"ensure_newline_at_eof_on_save": true, // 保存时自动在结尾追加空行
"trim_trailing_white_space_on_save": true // 保存时自动去掉尾部空格
}
Git Bash
// 设置鼠标选择时Copy,右键时粘贴
右键 -> Options -> Mouse
// 设置用户、邮箱信息(英文)
$ git config --global user.name alice
$ git config --global user.email alice@qq.com
// 提交时转换为LF,检出时不转换
$ git config --global core.autocrlf input
// 拒绝提交包含混合换行符的文件
git config --global core.safecrlf true
MarkdownPad
// 设置Tab转换为4个空格
Options -> Editor -> Editor Features 勾选 Insert Spaces ...
// 设置字符编码
Options -> character Encoding 勾选 Use Unix Style ...
Xshell
// 设置鼠标选择时Copy,右键时粘贴
选项 -> 键盘和鼠标 -> 鼠标
选项 -> 键盘和鼠标 -> 选择
PHPStrom
// 设置文件使用utf-8编码
Seetings -> File Encodings -> Global Encoding
Seetings -> File Encodings -> Project Encoding
Seetings -> File Encodings -> Properties Files
// 设置换行符
Seetings -> Editor -> Code Style -> Line separator 选择 unix and OS X
// 保存时自动在结尾追加空行
Seetings -> Editor -> General -> Other -> 勾选 Ensure line feed at file end on Save
// 保存时自动去掉多余空格
Seetings -> Editor -> General -> Other -> Strip trailing spaces on Save 选择 All
// 设置PHP代码风格
Seetings -> Editor -> Code Style -> PHP 点击右上角 Set from ... 选择PSR-2
// 项目注释
Seetings -> Editor -> File and Code Templates -> Includes -> PHP File Header
// 设置Terminal为Git Bash(Mac、Linux免设)
Seetings -> Tools -> Terminal -> Application settings -> Shell path 选择git bash的安装目录
以上配置有小编常用的配置,抽时候总结了一下分享出来,以后不用每次都到处百度了。