Atom Beautify with PHP and PHP-CS-Fixer on Windows
Sometimes making Atom Beautify work with PHP on Windows can be complicated. At least in my experience, it can happen that the Beautifier on Atom might stop working, or maybe with time there might be something not working well anymore, and it is a bit hard to understand which is the problem.
Let's see a possible solution, quite an easy one, that does not require to install either EasyPHP nor XAMPP.
Here are the steps and settings instructions to follow in order to make the Beautifer work with PHP and PHP-CS-Fixer.
- Download the PHP package based on your Windows version, like the VS16 x64 Thread Safe
- Download the .phar file for PHP-CS-Fixer by going on the website of Symfony and clicking on "Install now", the file name will be similar to "php-cs-fixer-v3.phar"
- Unzip the PHP archive downloaded at step 1, inside a folder called something like D:\Programs\php
- Put the php-cs-fixer-v3.phar file inside the same folder D:\Programs\php
- On Atom, install the Atom Beautify package
- Go to the settings of the Atom Beautify Package (on Atom) and at Executables write the absolute paths for PHP and PHP-CS-Fixer:
- for PHP it will be similar to D:\Programs\php\php.exe
- for PHP-CS-Fixer: D:\Programs\php\php-cs-fixer-v3.phar
- Close Atom and open it again. By pressing ALT+B on a PHP file the code will be formatted as for the standards.
In case of an error message, check that there are no other packages on Atom conflicting with Beautify, or try to double check that the settings of Atom Beautify are correct.
Let me know in the comments if this worked for you or not!