If you are a developer or you are handling a team of developers. It is always difficult to manage and understand their codes without proper alignment. Some of them even dont follow standard ways of writing codes. In Laravel, we can install php-cs-fixer so that we can run it and in a blink it can be seen proper formatted. It is life saver for lot of developers.

How to implement fixer in Laravel

In the command prompt, go to your root folder and run this command:

composer require stechstudio/laravel-php-cs-fixer

while setting up with above command, you may find error like not compatible with the php version. You can choose correct way or backward fixer in that case.

You can use following command and check either it is setting up correctly. It installs particular 1.* version.
composer global require friendsofphp/php-cs-fixer:1.*

How to run command

  1. Run fixer in particular folder

  2. php-cs-fixer fix folder_name
    eg: if you are running for app folder then:
    php-cs-fixer fix app

  3. Run fixer in whole application root folder

  4. Go out of root folder and run command:
    php-cs-fixer fix your_application_folder

Enjoy clean and clear codes.