Friday, November 13, 2015

PHP-CS-Fixer in PHPStorm with File Watcher

First of all, install php-cs-fixer:

wget -O php-cs-fixer
sudo chmod a+x php-cs-fixer
sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer

Second have a project-specific php-cs config file. As an example take a look here.

In PHPStorm click "File" -> "Settings" -> "Tools" -> "File Watchers"

Fill out the provided view:

Name: PHP CS Fixer
Description: fixes php code style
Show console: Error
File type: PHP
Scope: Project Files
Program: /usr/local/bin/php-cs-fixer
Arguments: --config-file=$ProjectFileDir$/.php_cs fix $FileDir$/$FileName$ -v --diff --dry-run
Working directory: $ProjectFileDir$

It should look like this:

PHPStorm Settings

Hint: You can also ommit the --dry-run option, to let PHP-CS-Fixer automatically fix your code.


  1. thx, one think yet: why should the wather not fix directly the violation at lookup?

  2. Thanks for sharing the valuable post. Kanhasoft is the well known Custom PHP Web Developer in India. We providing outsourcing services to USA, UK, Europe, Canada, Germany, UAE, Dubai, Australia, France, Brazil, Turkey, Singapore, Japan, Saudi Arabia, Ukraine, Spain, Belgium, Netherlands, Luxembourg, New Zealand, Argentina, South Africa, Greece, Denmark, Poland, Switzerland and more. Visit our site to know more.


  3. This is an awesome post. Really very informative and creative contents. This concept is a good way to enhance knowledge. I like it and help me to development very well. Thank you for this brief explanation and very nice information. Well, got good knowledge.
    best web design company in Chennai


  4. Contract PHP engineer capable in creating E-trade sites, shopping baskets, dynamic sites and customization of many open source applications. CakePHP Application Development

  5. Instead of HTML, PHP can develop relationship with databases, can make flat HTML code and you can even set your server to process all HTML archives with PHP so the real source code of your site can't be copied or seen.Why use Laravel

  6. The great information that you shared. It will help all of them. Thanks for posting. Keep maintain the updates
    PHP Development Company
    ERP Solution
    magento ecommerce

  7. This permits the maker to keep another substance from replicating the program and there is commonly no compelling reason to enroll code with the end goal for it to be copyrighted. itools crack 2020

  8. Thank you so much for sharing all this wonderful information !!!! It is so appreciated!! You have good humor in your blogs. So much helpful and easy to read!
    Software Testing course in Pune