☀ 必装插件
Php Inspections (EA Extended) // 代码审查分析插件,可帮助开发者找出有性能问题和安全问题的代码并提出优化建议
Chinese PHP Document // 内置函数中文文档
CodeGlance Pro // 在编辑区右侧显示代码迷你地图
PHP Toolbox // 代码自动补全、语法检查等功能
PHP Annotations // 注解工具
SonarLint // 代码质量检测
Rainbow Brackets // 彩虹括号
☀ 开启代码检查,如检查undefined、unused等
Editor > Inspection
☀ 屏蔽属性名/变量名过长或过短警告,有时候我们就是要使用类似$age的短单词
File > Settings > Editor > Inspections > PHP > Naming conventions > 修改Property name和Variable name的Min length和Max length即可
☀ 自动生成函数或方法的注释
☀ 全局查找和全局替换
项目根目录右键,弹出菜单里的“Find in Path”和“Replace in Path”分别是全局查找和全局替换
☀ 快捷键方案
File > Settings > Keymap
单行注释:搜索“Comment with Line Comment”,设为F1,重复一次可取消
多行注释:搜索“Comment with Block Comment”,设为F2,重复一次可取消
跳转到定义处:搜索“Declaration”,设为F3,支持跳转到变量、函数、方法、类的定义处
格式化代码:搜索“Reformat Code”,设为F4
展开代码块:搜索“Expand”,设为F5
折叠代码块:搜索“Collapse”,设为F6
展开全部代码:搜索“Expand All”,设为F7
折叠全部代码:搜索“Collapse All”,设为F8
删除光标所在行:搜索“Delete Line”,设为F9
复制光标所在行:搜索“Duplicate Line or Selection”,设为F10
大小写转换:搜索“Toggle Case”,设为F12
文档内搜索:搜索“Find”,设为Ctrl+F
文档内替换:搜索“Replace”,设为Ctrl+R
项目全局搜索:搜索“Find in Path”,设为Ctrl+Shift+F
项目全局替换:搜索“Replace in Path”,设为Ctrl+Shift+R
☀ 单行注释缩进并加空格
File > Settings > Editor > Code Style > PHP > Code Generation > Comment Code
取消:Line comment at first column # 缩进
勾选:Add a space at comment start # 加空格
☀ 修改PHP版本
File > Settings > Languages & Frameworks > PHP > 选择PHP Language level即可
☀ 导入/导出设置(重装PhpStorm就不需要再重新设置一遍快捷键和实时模板了)
File > Import Settings # 导入设置
File > Export Settings # 导出设置,文件保存为:/PhpStorm/bin/PhpStormConfig/config/settings.zip
☀ 快捷录入当前日期时间
☀ 跨脚本使用已定义变量提示“Undefined variable”(在A脚本定义变量$var,B脚本包含A脚本并使用变量$var)
File > Settings > Editor > Inspections > PHP > Undefined symbols > Undefined variable > Options
☑ Report that variable is probably undefined
☑ Enable inspection in global space
☑ Search for variable's definition outside the current file