zl程序教程

您现在的位置是:首页 >  后端

当前栏目

php strom教程,PhpStorm常用教程

PHP教程 常用 phpstorm
2023-06-13 09:15:15 时间

大家好,又见面了,我是你们的朋友全栈君。

一、PhpStorm 界面简化

Ctrl + Shift + A 查找快捷键

ALT+1 : 关闭或打开左边项目

二、PhpStorm 几个最重要的快捷键

快速查找文件:CTRL+SHIFT+N ==> Shift + F

显示文件有哪些方法:CTRL+F12 ==> Shift + F + M

最近打开文件:CTRL+E

查找方法名或类名:==> Shift + M

三、 PSR 自动加载支持:命名空间

四、快速创建文件:

alt + home

alt + insert

for win

五、自定义 file template

六、一键代码美化

phpstorm 默认的格式化代码的快捷键是 Ctrl + Alt + L,但是按了没有反应。 原因是当时开着网易云音乐,占用了这个快捷键,关了就好了

七、代码重构

7.1 代码重构:方法

选择要重构的代码片段

Ctrl + Alt + SHIFT + T

Method

7.2 代码重构:变量

八、多点编辑

win: ALT+J(选中) ALT+shift+J(撤销选中) Ctrl+ALT+shift+J(全部选中)

phpstorm 的代码注释有两种风格,一种是双斜杠注释 Ctrl + /,另一种是Ctrl + Shift + /: /* … */风格,两者的快捷键都是开关式(即按第一次为注释,再按一次为撤销注释)。

九、配置 PHP CS Fixer

### Globally (Composer)

To install PHP CS Fixer,[install Composer](https://getcomposer.org/download/)and issue the following command:

$ composer global require friendsofphp/php-cs-fixer

Then make sure you have the global Composer binaries directory in your`PATH`. This directory is platform-dependent, see[Composer documentation](https://getcomposer.org/doc/03-cli.md#composer-home)for details. Example for some Unix systems:

export PATH=”PATH:

.php_cs.dist

$finder = PhpCsFixer\Finder::create()

->exclude(‘somedir’)

->notPath(‘src/Symfony/Component/Translation/Tests/fixtures/resources.php’)

->in(__DIR__)

;

return PhpCsFixer\Config::create()

->setRules([

‘@PSR2’ => true,

‘strict_param’ => true,

‘array_syntax’ => [‘syntax’ => ‘short’],

‘list_syntax’ => [‘syntax’ => ‘long’],

‘single_quote’ => true, //简单字符串应该使用单引号代替双引号;

‘no_unused_imports’ => true, //删除没用到的use

‘no_singleline_whitespace_before_semicolons’ => true, //禁止只有单行空格和分号的写法;

‘self_accessor’ => true, //在当前类中使用 self 代替类名;

‘no_empty_statement’ => true, //多余的分号

‘no_extra_consecutive_blank_lines’ => true, //多余空白行

‘no_blank_lines_after_class_opening’ => true, //类开始标签后不应该有空白行;

‘include’ => true, //include 和文件路径之间需要有一个空格,文件路径不需要用括号括起来;

‘no_trailing_comma_in_list_call’ => true, //删除 list 语句中多余的逗号;

‘no_leading_namespace_whitespace’ => true, //命名空间前面不应该有空格;

‘standardize_not_equals’ => true, //使用 <> 代替 !=;

‘binary_operator_spaces’ => [‘default’ => ‘align_single_space’] //等号对齐、数字箭头符号对齐

])

->setFinder($finder)

;

运行命令:$ php-cs-fixer fix test.php –config=.php_cs.dist –allow-risky=yes

未完待续哦~

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/234182.html原文链接:https://javaforall.cn