Shareable php-cs-fixer config for your apps

Hey app developers,

we spent a bit of effort into building a unified and shareable configuration for the php coding style in Nextcloud server. The good news is that you can also use it to automatically format the code of your app.

You can find the config and instructions on Github: As always let me know if you have any feedback or need help with applying this to your app :slight_smile:

The dev docs for 19 will also have a note on this so it’s more discoverable

1 Like

Hi @ChristophWurst,

I’m glad to see your post as I’m struggling a bit to install and use php-cs-fixer and composer.

(My use case is to solve a php-cs check that failed when submitted a pull request on nextcloud server repo.)

On the one hand, I see from the links in your post that I should:

  • add package to dependencies (through ‘composer require’)
  • create a .php-cs-fixer.dist.php
  • install PHP CS Fixer with a composer.json in tools/php-cs-fixer folder
  • adapt composer.json

But on the other hand, I see in nextcloud/server repo that:

  • there is already a .php-cs-fixer.dist.php and a composer.json
  • there are already composer-related folders in build, lib, and vendor-bin folders (but not in a tools folder)
  • there are several ways to install composer, locally or globally.

So seeing these I’m not sure what to reuse without modification or what to install and modify.

Would you have a step by step tutorial that explains what to do from scratch ?

Thanks for your help.