0

(I know others have written about this, but the answers don't seem to help in this instance)

I have a WordPress PHP plugin (https://github.com/LiquidChurch/lqd-messages/) which uses WDS-Shortcodes which in turn uses TGM-Plugin-Activation. When I run composer install from within the lqd-messages plugin I get the following error:

In ClassMapGenerator.php line 69:

Could not scan for classes inside "/lqd-messages/vendor/webdevstudios/wds-shortcodes/vendor/tgmpa/tgm-plugin-activation/class-tgm-plugin-activation.php" which does not appear to be a file or folder"

I can then go into /lqd-messages/vendor/webdevstudios/wds-shortcodes/vendor and see that there is no tgmpa folder.

If I then go back to /wds-shortcodes and run composer install, the tgmpa folder will be successfully created.

Obviously, this is less than ideal. Is there a way to get around these extra steps?

Dave Mackey
  • 4,306
  • 21
  • 78
  • 136

1 Answers1

2

This is bug in webdevstudios/wds-shortcodes package - their autoloadig settings are incorrect. Dependencies should not declare loading files from other dependencies inside of vendor directory - this is not their concern (and these files will not exist in some scenarios, like yours).

I can only recommend forking this package and fixing autoloading settings:

"autoload": {
    "classmap": ["includes/"]
},

BTW: You've made the same mistake in your package.

rob006
  • 21,383
  • 5
  • 53
  • 74
  • Thanks! I guess my question is, how do I ensure then that the tgmpa plugin is loaded if not using the autoloader? – Dave Mackey Jan 13 '20 at 20:27
  • 2
    You can use autoloader from Composer, you just should not declare autoloading files from `vendor` directory. Each package should define autoloading only for its own files - Composer will combine autoloading from all installed packages. – rob006 Jan 13 '20 at 21:02
  • Thanks! I did as you suggested and I've progressed. I'm still getting one more error, hoping you can help me with. wds-shortcodes requires jtsternberg/shortcode-button (I removed the automap). But even with this removed I'm getting an error when trying to run phpunit: "`/long/path/lqd-messages/vendor/php un /long/path/lqd-messages/vendor/webdevstudios/wds-shortcodes/vendor/jtsternberg/shortcode-button/shortcode-button.php on line 97`". – Dave Mackey Jan 13 '20 at 21:54