phpStrom 安装php代码格式化插件php-cs-fixer

1、安装
安装很简单,下载php-cs-fixer.phar文件就行了。
官方地址是:
http://get.sensiolabs.org/php-cs-fixer.phar

github地址:
https://github.com/FriendsOfPHP/PHP-CS-Fixer

2、添加

进入phpStrom Settings -> Tools -> External Tools

    1. 参数解读

      Program:你的php编译程序的路径

      Parameters: E:php-cs-fixerphp-cs-fixer.phar fix  --using-cache no --config=E:php-cs-fixer.php_cs.dist $FileDir$$FileName$ 
      其中:

      E:php-cs-fixerphp-cs-fixer.pha是你步骤1中你下载的php-cs-fixer的路径 --using-cache no 不使用缓存
      ---config=E:php-cs-fixer.php_cs.dist使用项目目录下的.php_cs模板也可以使用下面的参数自己指定psr2或者其他标准格式化代码

    2. Working Directory: 工作目录 $ProjectFileDir$

3、配置phpStrom快捷键

重新进入phpStrom-> Settings->Appearance & Behavior -> Keymap

使用查找 php-cs-fixer

 添加格式化时使用的快捷键,我这里使用的是Alt+Shift+;   

你可以设定你自己的快捷键。
安装完成,现在当你使用phpStrom便捷文件想格式化代码时,你就可以使用你设定的快捷键格式化代码
效果图:

 

原文地址:https://www.cnblogs.com/-mrl/p/14120702.html