DEV Community 👩‍💻👨‍💻

Cover image for How I was able to install php-cs-fixer. Vscode + Linux machine
Chidiebere Chukwudi
Chidiebere Chukwudi

Posted on

How I was able to install php-cs-fixer. Vscode + Linux machine

What caused me to write this article was after a frequent failed lint test for an open source organisation that I'm currently contributing to via google summer of code.

The resource I used for installation but wait..

To be bit a elaborate and for a proper updated installation process, here is what I did: I used the latest version of php-cs-fixer then entered the command that followed to install php-cs-fixer.

wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.10.0/php-cs-fixer.phar -O php-cs-fixer

chmod +x php-cs-fixer

sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer

sudo chown -R user name: /usr/local/bin/php-cs-fixer
Enter fullscreen mode Exit fullscreen mode

Note: Adding sudo often require that you put password- please put your password. The part that says username should be replaced with your linux machine's username
After that run the following command:

php-cs-fixer
Enter fullscreen mode Exit fullscreen mode

You should see something like the screenshot below:

php cs fixer

Then to lint a php file, open that file with a text editor and in the terminal you can run

php-cs-fixer fix
Enter fullscreen mode Exit fullscreen mode

That will do!

Lets make php cs fixer work naturally on vscode.

By doing this, we don't always have to type the command, php-cs-fixer, in vscode terminal.

Then install php-cs-fixer vscode extension by junstyle.

Next, Open a php file that you will like to lint using vscode text editor.
On vscode, Click on settings (Linux: ctrl + ,).
In the settings search bar, search for php-cs-fixer executable path, you should see something like this below:

php-cs-fixer
In the executable path field, enter the following:
/usr/local/bin/php-cs-fixer.

That should be it! You can lint your code now: press F1 or ctrl + Shift + I.

That should be all.
Linkedin.

Cover image credits
pixabay. Annushka Ahuja:

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.