WordPress / WordPress-Coding-Standards

PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
MIT License
2.53k stars 471 forks source link

Consider releasing as .phar #375

Closed danielbachhuber closed 7 years ago

danielbachhuber commented 9 years ago

To reduce the dependency on Composer, or make the project available to projects already using Composer, it would be nice if WPCS was available as a .phar standalone.

Related https://github.com/wp-cli/wp-cli/issues/1816

GaryJones commented 9 years ago

Forgive my ignorance, but what's involved in creating a .phar?

Edit: http://www.sitepoint.com/packaging-your-apps-with-phar/ http://php.net/manual/en/book.phar.php

danielbachhuber commented 9 years ago

Yep, the Sitepoint article looks like a good reference. You could also crib from WP-CLI: https://github.com/wp-cli/wp-cli/blob/master/utils/make-phar.php

GaryJones commented 7 years ago

For those using Composer, and with the support of the https://github.com/DealerDirect/phpcodesniffer-composer-installer plugin, the setup seems to be quite manageable with the need for a .phar.

For those not using Composer, yes, it definitely makes things trickier. What would be the workflow of using (presumably) the PHPCS .phar with a WPCS .phar?

And as Composer gets ever increasingly used, is the effort to have a build process for a .phar worth it? cc @WordPress-Coding-Standards/wpcs-admins

JDGrimes commented 7 years ago

I've never used phars personally, but perhaps they are still useful to people. I don't think that WPCS alone could be packaged into a phar, unless PHPCS specifically supports standards in phar format. I'm guessing that PHPCS might need to be included along with WPCS in the phar package. I have no experience with phars though, so I might be wrong.

GaryJones commented 7 years ago

I'm guessing that PHPCS might need to be included along with WPCS in the phar package.

That's pretty much my workflow question.

My current workflow uses WPCS/PSR-2, PHPCompatibility and ObjectCalisthenics PHPCS code standards. Trying to bundle WPCS up with PHPCS (if that's what would need to happen) would make it less likely to encourage others to use the other useful standards as well.

jrfnl commented 7 years ago

I personally use a phar version of PHPUnit which works nicely.

PHPCS itself is also available as a phar and has a build script for it. I'm not sure if PHPCS supports external standards provided as a phar, but that could be tested of course (or just asked in an issue upstream).

If it doesn't or if PHPCS would have to be shipped in the WPCS phar, then I'm definitely with @GaryJones as discouraging the use of other external standards should be avoided.

Rarst commented 7 years ago

or make the project available to projects already using Composer

I don't quite follow this bit... If a project is using Composer — just use WPCS as development dependency and you are peachy?

While I like phars myself (and tinkered with making some before, using https://github.com/box-project/box2 ) I am not sure the structure of PHPCS+WPCS bundle applies cleanly to it:

  1. Can PHPCS even work with standards within phar?
  2. Would customization work smoothly? Myself I have a highly customized WP ruleset, on top of WPCS.
  3. How would it operate with other standards, not included in phar? (Was raised already).

Overall I am busy with work project and can't jump on it right now, but think it's worth at least an evening of doing proof of concept some time and seeing how it goes.

GaryJones commented 7 years ago

Since there's some confusion about the viability, let alone usefulness, of this, I'm going to make an executive decision to close this for now. If Rarst or anyone gets around to showing how this can work, then it can be re-opened if needed.