gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 12:53:06 26 4
gpt4 key购买 nike

在我的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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com