打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
phpstorm php-cs-fixer代码格式化

1、获取

2、安装

新建composer.json 文件

{
 "require" :{
   "fabpot/php-cs-fixer":"2.16.3"
 },"config": {
 "secure-http": false
   }
}

这里注意你要使用的php-cs-fixer 的版本

在命令行执行 composer update 命令

3、配置

设置全局:

找到安装目录 设置全局变量 D:\tools\php-cs-fixer\vendor\bin

在PHPstorm 中 新增工具插件

Name: php-cs-fixer
Program: D:\tools\php-cs-fixer\vendor\bin\php-cs-fixer.bat
Arguments: fix $FileDir$/$FileName$ --config=.php_cs.dist
Working director: $ProjectFileDir$

4、注意项

  • 一定要保证安装的php-cs-fixer版本和 .php_cs.dist 保持一致

  • Arguments的值设置为  fix $FileDir$/$FileName$ --config=.php_cs.dist 这样 是针对单文件进行格式化的,如果想要批量针对指定目录下的所有文件 需要修改为  fix $FileDir$ --config=.php_cs.dist 

 版本3

  • 第一种

$ mkdir --parents tools/php-cs-fixer
$ composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer
  • 第二种 新增comopser.json 文件 然后执行 composer update

{
 "require": {
  "friendsofphp/php-cs-fixer": "^3.8"
 }
}

在phpstorm中  File | Settings | Tools | External Tools 增加扩展工具类

Name: php-cs-fixer3
Program: D:\tools\php-cs-fixer\vendor\bin\php-cs-fixer.bat
Arguments: fix $FileDir$/$FileName$ --config=.php-cs-fixer.dist.php
Working director: $ProjectFileDir$

不凡笔记:http://upwqy.com/?p=388
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
composer
编程语言关于PHPstorm 使用技巧,PHPstorm使用技巧_PHP教程
【excel】php框架laravel excel包使用教程介绍
composer windows安装,使用新手入门
正版phpstorm免费激活步骤(图文详解)
composer 安装
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服