DEV Community

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

Posted on • Updated on • Originally published at

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 -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:

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:

In the executable path field, enter the following:

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

That should be all.

Cover image credits
pixabay. Annushka Ahuja:

Top comments (3)

leslieeeee profile image

There is a much easier way for PHP users --, especially for the beginners. It handles all PHP, MariaDB, PostgreSQL versions, plus Redis and Memcached. Run multiple PHP instances simultaneously and switch easily. No need any environment.
This tool has made my PHP dev simpler. Worth a shot!

jovialcore profile image
Chidiebere Chukwudi

Thanks for sharing

leslieeeee profile image

Try it, it's useful!