Create a gist now

Instantly share code, notes, and snippets.

Embed
@fabpot php-cs-fixer config for PhpStorm
parameters
--level=psr2 --verbose fix $FileDir$/$FileName$
working directory
$ProjectFileDir$
@Soullivaneuh

This comment has been minimized.

Show comment
Hide comment
@Soullivaneuh

Soullivaneuh May 27, 2015

Looks interesting.

Where should I put this 4 code lines? Is will files be automatically fixed on save?

Thanks.

Looks interesting.

Where should I put this 4 code lines? Is will files be automatically fixed on save?

Thanks.

@mpalourdio

This comment has been minimized.

Show comment
Hide comment
@mpalourdio

mpalourdio Jun 1, 2015

Go to settings, and configure a new external tool. Fill Parameters and working directory as specified.

No 'fix on save', just run the tool when needed, or configure a pre-commit hook.

Owner

mpalourdio commented Jun 1, 2015

Go to settings, and configure a new external tool. Fill Parameters and working directory as specified.

No 'fix on save', just run the tool when needed, or configure a pre-commit hook.

@teameh

This comment has been minimized.

Show comment
Hide comment
@teameh

teameh Oct 2, 2015

Works like a charm, thnx

image

teameh commented Oct 2, 2015

Works like a charm, thnx

image

@bvarent

This comment has been minimized.

Show comment
Hide comment
@bvarent

bvarent Jan 6, 2016

Use $FilePath$ instead of $FileDir$/$FileName$ to support directories properly.

bvarent commented Jan 6, 2016

Use $FilePath$ instead of $FileDir$/$FileName$ to support directories properly.

@trunda

This comment has been minimized.

Show comment
Hide comment
@trunda

trunda Apr 3, 2016

'Fix on save' can be achieved by macro, if you are interested. Thank you for the gist, which was helpful for me.

trunda commented Apr 3, 2016

'Fix on save' can be achieved by macro, if you are interested. Thank you for the gist, which was helpful for me.

@ksassnowski

This comment has been minimized.

Show comment
Hide comment
@ksassnowski

ksassnowski May 25, 2016

You can also use a File Watcher to enable fix on save. The configuration stays exactly the same.

bildschirmfoto 2016-05-25 um 10 37 59

Thanks to simonneaves below for pointing out that you probably want to untick 'Immediate file synchronization'. Otherwise it will run the command on every key stroke which is definitely not what you want!

ksassnowski commented May 25, 2016

You can also use a File Watcher to enable fix on save. The configuration stays exactly the same.

bildschirmfoto 2016-05-25 um 10 37 59

Thanks to simonneaves below for pointing out that you probably want to untick 'Immediate file synchronization'. Otherwise it will run the command on every key stroke which is definitely not what you want!

@simonneaves

This comment has been minimized.

Show comment
Hide comment
@simonneaves

simonneaves Jun 4, 2016

Thanks kssassnowski. For fix on save, rather than 'fix as you type', I unticked 'Immediate file synchronization'.

Thanks kssassnowski. For fix on save, rather than 'fix as you type', I unticked 'Immediate file synchronization'.

@j3rrey

This comment has been minimized.

Show comment
Hide comment
@j3rrey

j3rrey Jun 22, 2016

And you should have php-cs-fixer installed on ur machine,
composer require friendsofphp/php-cs-fixer

For the lazy devs out there:
Program:
[Your composer Path].composer/vendor/bin/php-cs-fixer
Arguments:
fix $FileDir$/$FileName$ --level=psr2 and whatever else u want to use --fixers=symfony
Working directory:
$ProjectFileDir$

j3rrey commented Jun 22, 2016

And you should have php-cs-fixer installed on ur machine,
composer require friendsofphp/php-cs-fixer

For the lazy devs out there:
Program:
[Your composer Path].composer/vendor/bin/php-cs-fixer
Arguments:
fix $FileDir$/$FileName$ --level=psr2 and whatever else u want to use --fixers=symfony
Working directory:
$ProjectFileDir$

@sergiodebcn

This comment has been minimized.

Show comment
Hide comment
@sergiodebcn

sergiodebcn Dec 5, 2016

Thanks for the info, very useful

Thanks for the info, very useful

@mcfedr

This comment has been minimized.

Show comment
Hide comment
@mcfedr

mcfedr Feb 8, 2017

Excellent, my changes, just as a note, as I am using a config file:
Arguments:
fix -v --config .php_cs.dist --path-mode=intersection -- $FilePath$

mcfedr commented Feb 8, 2017

Excellent, my changes, just as a note, as I am using a config file:
Arguments:
fix -v --config .php_cs.dist --path-mode=intersection -- $FilePath$

@skoop

This comment has been minimized.

Show comment
Hide comment
@skoop

skoop Apr 24, 2017

thank you @ksassnowski, I've just used that to set it up for me. works like a charm

skoop commented Apr 24, 2017

thank you @ksassnowski, I've just used that to set it up for me. works like a charm

@shadypierre

This comment has been minimized.

Show comment
Hide comment
@shadypierre

shadypierre May 3, 2017

--level doesn't exist anymore, for an updated config take a look at : https://hackernoon.com/how-to-configure-phpstorm-to-use-php-cs-fixer-1844991e521f

--level doesn't exist anymore, for an updated config take a look at : https://hackernoon.com/how-to-configure-phpstorm-to-use-php-cs-fixer-1844991e521f

@mfour-merickson

This comment has been minimized.

Show comment
Hide comment
@mfour-merickson

mfour-merickson Oct 24, 2017

@mcfedr Perhaps you would not mind sharing your config file? I have pretty sensible defaults but always intrigued by what others are using.

@mcfedr Perhaps you would not mind sharing your config file? I have pretty sensible defaults but always intrigued by what others are using.

@unglud

This comment has been minimized.

Show comment
Hide comment
@unglud

unglud Dec 1, 2017

If I put it to After Commit Run Tool how can I fix all commited files instead only one currently opened?

unglud commented Dec 1, 2017

If I put it to After Commit Run Tool how can I fix all commited files instead only one currently opened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment