
PHPCS is an open-source command-line tool designed to identify code style violations based on defined coding standards. Additionally, it offers automatic fixes for rules that can be corrected automatically.
For Mac users, installing PHP and Composer is straightforward using Laravel Herd. Visit the Laravel Herd website, download the package, and follow the simple instructions.
After completing the installation, ensure that PHP and Composer are installed correctly by running the following commands in your terminal:
php --version
composer --version
If both are installed correctly, the terminal will display the respective version numbers.

Follow these simple instructions to install PHPCS on your machine:
cd
mkdir .composer
cd .composer
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar

php phpcs.phar -h
Currently, checking a PHP file with PHPCS involves navigating to the ~/.composer folder and typing php phpcs.phar each time, along with the full path of the PHP file.
To streamline this process:
cd ~/.composer
pwd
nano ~/.zshrc
alias phpcs='php /Users/arya/.composer/phpcs.phar'
cmd+o, then enter, and exit with cmd+x.phpcs -h to ensure PHPCS is available globally.
PHPCS is now globally accessible.
Open any PHP project in your terminal and run PHPCS on a PHP file. For example, if you have a test project in ~/Herd with an index.php file, you can check it by typing:
phpcs index.php
PHPCS will display a list of errors and warnings, guiding you on improving your code.
Here’s My index.php file’s code

Yes, that’s simple, it will show you errors and warning list line by line in the terminal,

This feedback from PHPCS not only points out errors but also suggests ways to enhance your code.
In a future post, we can delve into how to configure PHPCS to use specific coding standards, customize rules, and even create your own custom rules. Understanding and utilizing different rule sets allows developers to tailor PHPCS to their preferred coding style or adhere to industry standards
Also in future posts, we’ll explore how to address these issues using the helpful PHPCBF tool. Stay tuned for more insights and tips!