用于 cloud9 IDE 的 PHP 美化器/格式化器

标签 php cloud9-ide formatter cloud9

在我的Cloud09 IDE我启用了 PHP 设置“自定义代码格式化程序”

但保存时出现错误:No code formatter set for php: please check your project settings 没有像 JS 那样预定义的格式化程序 (esformatter -i "$file") 和谷歌也没有帮助...

enter image description here

如何使用此设置?

如何在 Cloud9 上安装 PHP 格式化程序?

我唯一的搜索显示 this Pear package但它似乎已经过时了。

最佳答案

下载php-cs-fixer https://github.com/FriendsOfPHP/PHP-CS-Fixer到您的 Cloud9 工作区:

$ wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.0.0/php-cs-fixer.phar -O ~/php-cs-fixer

把它放在你的~/bin目录下:

$ mkdir ~/bin; mv ~/php-cs-fixer ~/bin

使文件可执行:

$ chmod a+x ~/bin/php-cs-fixer

为 PHP 配置 IDE 的自定义代码格式化程序设置,以将格式化程序与 whatever rules you want 一起使用:

php-cs-fixer fix "$file" --rules=@Symfony,@PSR2

这就是我的 ~/workspace/.c9/project.settings 文件的样子:

...
"php": {
    "@completion": true,
    "@formatOnSave": true,
    "@formatter": "php-cs-fixer fix \"$file\" --rules=@Symfony,@PSR2",
    "@path": ".:./vendor:/usr/local/bin"
},
...

关于用于 cloud9 IDE 的 PHP 美化器/格式化器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40972683/

相关文章:

php - 如何使用 API/Frontend/etc 构建 Laravel 系统

node.js - 无法在云IDE中运行meteor,需要帮助了解meteor内存使用情况

java - 带有 TextFormatter 和/或 UnaryOperator 的 JavaFX 8 中用于整数的数字文本字段

jquery - jQuery jqGrid 的自定义下拉格式化程序

java - 格式化程序类无法正常工作

php - Magento后端错误 "Front controller reached 100 router match iterations"

php - Laravel 中的路由模型绑定(bind)和父子验证

php - 在 PHP 中生成带有偏差结果的随机数

typescript 和cloud9 ide如何?

sqlite - 如何在cloud9 ide上查看或编辑sqlite db记录?