How To Install php-cs-fixer on CentOS 7

In this tutorial we learn how to install php-cs-fixer on CentOS 7. php-cs-fixer is A tool to automatically fix PHP code style

Introduction

In this tutorial we learn how to install php-cs-fixer on CentOS 7.

What is php-cs-fixer

The PHP Coding Standards Fixer tool fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents and many more. If you are already using a linter to identify coding standards problems in your code, you know that fixing them by hand is tedious, especially on large projects. This tool does not only detect them, but also fixes them for you.

We can use yum or dnf to install php-cs-fixer on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install php-cs-fixer.

Install php-cs-fixer on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

After updating yum database, We can install php-cs-fixer using yum by running the following command:

sudo yum -y install php-cs-fixer

Install php-cs-fixer on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

After updating yum database, We can install php-cs-fixer using dnf by running the following command:

sudo dnf -y install php-cs-fixer

How To Uninstall php-cs-fixer on CentOS 7

To uninstall only the php-cs-fixer package we can use the following command:

sudo dnf remove php-cs-fixer

References

Summary

In this tutorial we learn how to install php-cs-fixer on CentOS 7 using yum and dnf.