Dave Mackey
Dave Mackey

Reputation: 4432

How to avoid "Could not scan for classes inside" error with Composer?

(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?

Upvotes: 0

Views: 547

Answers (1)

rob006
rob006

Reputation: 22174

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.

Upvotes: 2

Related Questions