mezzio / mezzio-skeleton

Laminas mezzio skeleton. Begin developing PSR-15 middleware applications in seconds!
https://docs.mezzio.dev/mezzio/
BSD 3-Clause "New" or "Revised" License
120 stars 31 forks source link

Missing PHPCS dependency #68

Closed brayniverse closed 9 months ago

brayniverse commented 2 years ago

Bug Report

Q A
Version(s) 3.11.0

Probably affects other versions but I'm fairly sure that's the version I installed.

Summary

PHPCS comes installed via laminas/laminas-coding-standard but that is removed after the installer script is run. As a result the composer check and composer cs-check commands are broken.

Current behavior

When you run composer check you get the following error message:

> phpcs
'phpcs' is not recognized as an internal or external command,
operable program or batch file.
Script phpcs handling the cs-check event returned with error code 1
Script @cs-check was called via check

If you manually install squizlabs/php_codesniffer it will find PHPCS but then you get the following error:

> phpcs
ERROR: Referenced sniff "LaminasCodingStandard" does not exist

Run "phpcs --help" for usage information

Script phpcs handling the cs-check event returned with error code 3

How to reproduce

Install a fresh instance of mezzio/mezzio-skeleton either using composer create-project mezzio/mezzio-skeleton or by manually cloning the repository and running composer install or composer update.

Once installed run the composer check or composer cs-check commands.

Expected behavior

I would expect to see the output from PHPCS.

brayniverse commented 2 years ago

I'm happy to submit a pull request to resolve this issue. But first I'd need someone in charge to tell me what you'd like me to do first.

I was thinking of adding squizlabs/php_codesniffer as a dev dependency and creating src/MezzioInstaller/Resources/phpcs.xml.dist with config similar to the current phpcs.xml.dist but with the PSR12 standard instead of LaminasCodingStandard, then making sure it replaces the original phpcs.xml.dist after install.

Please let me know if there is anything I can do to help.

arueckauer commented 2 years ago

Interesting observation. I usually do add laminas-coding-standard manually but also remove the script section from composer.json as I do not rely on these.

Adding laminas-coding-standard to a newly created project is trivial. The question I have, is, is it really desired to ship laminas-coding-standard with the skeleton? What if someone prefers friendsofphp/php-cs-fixer or doctrine/coding-standard?

It would be possible to add a choice during installation. Personally I'd rather not and let the user decide what coding standard, static code analysis tool etc. he/she would like to install. I would vote for removing the cs-related scripts from composer.json.

brayniverse commented 2 years ago

I would be happy with removing PHP CS entirely and installing it myself with each project. But having it there pre-installed and pre-configured would definitely be convenient for me and possibly newcomers to the framework who might not yet have experience with automated coding standards.

So long as it's either removed completely to avoid confusion or working on a fresh install I'm happy.

brayniverse commented 2 years ago

Hi @froschdesign @Ocramius.

Sorry to bother you both but you interacted with me on a PR I submitted recently so I assume you're both working on this repository at the moment.

I would like to help resolve this issue. Is there anything I can do to help? As I said in an earlier comment, I'm happy to put together a pull request if you can give me directions on what you'd like to be done.

Ocramius commented 2 years ago

Send a patch: easier to review a diff.

brayniverse commented 2 years ago

Working on it.

oleg-moseyko commented 1 year ago

$ composer check

phpcs sh: phpcs: command not found Script phpcs handling the cs-check event returned with error code 127 Script @cs-check was called via check