Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laracoft's avatar

.php_cs config for php-cs-fixer

  1. Where can I find the most "official" .php_cs for Laravel? https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 ???
  2. Is there one that properly handles indentation in a switch?
  3. Feel free to share why/how you chose yours
0 likes
3 replies
MarianoMoreyra's avatar

Hi @laracoft

Based on this comment at the link you’ve shared: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200#gistcomment-3068167

I’d say that it’s pretty much “official” as it matches the Laravel preset at StyleCI

Anyway, recently I’ve used this one: https://github.com/barryvanveen/barryvanveen/blob/master/.php_cs

As it’s based on symfony rules plus some minor changes resulting in a really simple config file. Also, in my case it was the one that better suited my needs for styling a contribution for SocialiteProviders package

laracoft's avatar

@marianomoreyra

Thanks, I'm on VSCode and was playing around with the following:

  1. phpfmt
  2. php-cs-fixer https://github.com/FriendsOfPHP/PHP-CS-Fixer
  3. php-codesniffer https://github.com/squizlabs/PHP_CodeSniffer

Believe it or not, I moved away from php-cs-fixer to phpfmt. Not sure why, but php-cs-fixer seems to have changed recently and doing less than before, it doesn't indent my code properly.

phpfmt handles code in switch() nicely. Mind showing how your php-cs-fixer indents code in switch()?

Please or to participate in this conversation.