Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach IDEs to look at our vendor PHPCS file for auto linting? #23

Closed
mattstauffer opened this issue Feb 9, 2021 · 3 comments
Closed

Comments

@mattstauffer
Copy link
Member

One of the big benefits of going with PHPCS is getting the thing where the IDE reads it and gives you inline linting that matches up with your spec.

But.. we have to figure out how to make the config files available to the IDEs, since they're in the vendor folder, not root.

I've been trying to avoid a workflow that requires every user to publish config files into their root; is there any other way to do it?

I'd like to solve at least PHPStorm and VS Code, and Sublime would be nice too.

@jonsugar
Copy link
Contributor

jonsugar commented Feb 12, 2021

PHPCS working in PHPStorm using Tighten's config from the vendor directory.

image

And now how to configure it…

Enable PHPCS

  1. Open composer.json and click the settings cog next to the phpcodesniffer dependency.

image

  1. Fill in the path to phpcs and phpcbf.

image

Configure the CodeSniffer Inspection

  1. Go to Settings > Editor > Inspections
  2. Open the PHP > Quality Tools > PHP_CodeSniffer validation inspection.
  3. Set Coding standard to custom.
  4. Click the to the right of custom .

image

  1. add the path to the .phpcs.xml.dist within the vendor directory.

image

@mattstauffer
Copy link
Member Author

Thanks! I'm starting to think the only good way to handle this in all editors is to either A) publish the configs to the root directory by default or B) symlink them to the root by default, even with that clever PHPStorm fix you have there.

One idea is to have Duster publish a PHPCS standard and then "publish" would just output a local file that applies that standard to all of your local directories, so we can still iterate on the PHPCS standard.

I dropped PHP-CS-Fixer and Duster's Tlint config is just Tighten's, so that doesn't need to be published at all.

I think I'm leaning in that direction right now.

@mattstauffer
Copy link
Member Author

OK, latest release publishes .phpcs.xml.dist by default, so I think this is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants