[英]atom-beautify & php-cs-fixer
我是一個新程序員,我需要你的幫助。 我對 Atom 編輯器很陌生,但設置了一些不錯的軟件包,例如 Atom Beautify。 在html/php文件中使用它后,我收到錯誤“找不到 'php-cs-fixer' 。程序可能未安裝。奇怪的是,我確實安裝了 php-cs-fixer 包,但是沒發生什么事。
我的系統是Windows。
任何人都知道我該如何解決這個問題?
通常在安裝 Wamp 或 Xampp 服務器時,您通常必須安裝“php”。
下載文件“php-cs-fixer.phar” https://github.com/FriendsOfPHP/PHP-CS-Fixer
在 CMD 中執行此命令: php where.exe
你得到一個路徑,該路徑復制到:Open Atom Packages / Atom Beautify / Settings / Executables / PHP
在 php.exe 所在的文件夾中復制文件“php-cs-fixer.phar”
使用 PHP-CS-Fixer 中的 CMD 和 Atom 重做之前的過程”
我不確定在 Windows 中,但在 Mac 和 Linux 上,我執行以下操作。 您可以使用 Windows 中的 Git Bash 來完成此操作。
使用Homebrew安裝 php-cs- fixer (通過PHP-CS-Fixer 說明)
brew install php-cs-fixer
確認 php-cs-fixer 已安裝
which php-cs-fixer
這是因為您需要安裝 php cs fixer,atom 擴展正在嘗試使用它,但它當前未安裝在您的系統上,請在此處安裝: https : //github.com/FriendsOfPHP/PHP-CS-Fixer
我建議您使用以下步驟手動安裝 php-cs-fixer:
whereis php-cs-fixer
進行了檢查,我得到了/usr/bin/php-cs-fixer
Packages > Atom Beautify > Settings > Executables > PHP-CS-FIXER
然后在Binary/Script Path
給出上面 php-cs-fixer 的路徑( /usr/bin/php-cs-fixer
)我的問題最初是用作曲家安裝的。 Composer 不會將 .phar 文件放入 /bin 文件夾。
下載 .phar 文件( https://github.com/FriendsOfPHP/PHP-CS-Fixer#locally )並將其顯式放置在某個位置,然后將該位置放在 settings->executables->PHP-CS-Fixer 路徑中
只需在終端中運行此命令,它就會完美運行:
$ composer global require friendsofphp/php-cs-fixer
一切都會好起來的!
手動方式確實對我有用,這就是我的做法;
php-cs-fixer
。 $ wget https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer
或curl
$ curl -L https://cs.symfony.com/download/php-cs-fixer-v3.phar -o php-cs-fixer
$ sudo chmod a+x php-cs-fixer
$ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
php-cs-fixer
並且成功了。完整鏈接
composer require friendsofphp/php-cs-fixer
C:\\Programs\\php-cs-fixer\\vendor\\bin\\php-cs-fixer.bat
C:\\Programs\\php-cs-fixer\\vendor\\bin
到 windows env 路徑,以便您可以從 cli 使用它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.