Skip to content

Instantly share code, notes, and snippets.



Last active Nov 19, 2018
What would you like to do?
Use php-cs-fixer with phpstorm file watcher

Auto use php-cs-fixer at save with PHPStorm and file watcher

  1. Open settings ( ctrl + alt + s)
  2. Menu file watchers
  3. Import watchers.xml
  4. Change settings like path for php and php-cs-fixer
  5. Enjoy ! PSRize at save.

NB: File watchers are linked to a specific project, so we have to re-import them for each project. External tools have IDE scope but we couldn't run them automaticaly - we could set a key bind.

<?xml version="1.0" encoding="UTF-8"?>
<option name="arguments" value="C:\php-5.5\php\php-cs-fixer.phar fix $FileDir$/$FileName$ --level=psr2" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" value="" />
<option name="exitCodeBehavior" value="ALWAYS" />
<option name="fileExtension" value="php" />
<option name="immediateSync" value="true" />
<option name="name" value="cs fixer" />
<option name="output" value="" />
<option name="outputFilters">
<array />
<option name="outputFromStdout" value="false" />
<option name="passParentEnvs" value="true" />
<option name="program" value="C:/php-5.5/php/php.exe" />
<option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="false" />
<option name="workingDir" value="$ProjectFileDir$" />
<envs />

This comment has been minimized.

Copy link

@Ejdems666 Ejdems666 commented Apr 13, 2018

Why is the programme php and not php-cs-fixer? I switched that and it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.