Skip to content

Instantly share code, notes, and snippets.

@kefzce
Forked from kandran/README.md
Created November 13, 2018 00:59
Show Gist options
  • Save kefzce/eb0d81e85d92e83f430b3c2a651cc0eb to your computer and use it in GitHub Desktop.
Save kefzce/eb0d81e85d92e83f430b3c2a651cc0eb to your computer and use it in GitHub Desktop.
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"?>
<TaskOptions>
<TaskOptions>
<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>
<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 />
</TaskOptions>
</TaskOptions>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment