Open robertmathews opened 7 years ago
Why not just install the underlying package in that case and run that ? After all, the plugin is not much more but a shell around it: https://github.com/wimg/phpcompatibility
Sure, that would work. But of course if you already use wp-cli and have it deployed, wp package install git://github.com/wpengine/phpcompat.git
is simpler than installing https://github.com/wimg/phpcompatibility and PHP CodeSniffer separately.
I was mostly just surprised it didn't already work that way, and was wondering if it would be a trivial change to make it work by including the WP_CLI::add_command in the file autoloaded by composer.json.
Hi @robertmathews! I honestly haven't tried that and I'm not sure what it would take. We include the WP-CLI command if WP_CLI is defined here:
https://github.com/wpengine/phpcompat/blob/master/wpengine-phpcompat.php#L17
I'm curious if this could be causing the breakdown. Here they use a different check:
https://github.com/wp-cli/scaffold-package-command/blob/master/templates/command.mustache#L1
I don't have too much time to dig into it at the moment but if it's something easy I'd be happy to deploy it.
I don't know much about Composer, unfortunately, but it seems that this line is never even called when run from wp-cli:
https://github.com/wpengine/phpcompat/blob/master/wpengine-phpcompat.php#L17
Comparing it to other packages, others seem to autoload the file that contains the "add_command", like:
https://github.com/wp-cli/scaffold-package-command/blob/master/composer.json#L21
I tried editing phpcompat's composer.json to do the same thing, which allows it to load "wpcli.php", but then it gives errors:
PHP Fatal error: require_once(): Failed opening required '/[...]/.wp-cli/packages/local/wpengine-phpcompat/src/../vendor/autoload.php' (include_path='.:/usr/share/php') in /[...]/.wp-cli/packages/local/wpengine-phpcompat/src/wpcli.php on line 2
This works fine for me via wp-cli when php-compatibility-checker is installed as a WordPress plugin on the site in question. However, I'd like to be able to run it even if not installed as a plugin on the site.
I tried installing it globally and it appears as a wp-cli package, but doesn't actually provide the command:
Am I missing some way to do this? Or is it currently not possible?