generator-craftplugin icon indicating copy to clipboard operation
generator-craftplugin copied to clipboard

Composer 2.0 type warnings

Open loqus opened this issue 5 years ago • 4 comments

Question

I generated a module a year ago and it works really well, but the last months after running composer update i get an error message like "does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0.".

Is that something you can fix in a future generator? Or maybe change the readme to incorporate changes for composer v2

loqus avatar Nov 05 '20 19:11 loqus

This should be fixed in an update here. Can you show us which classes/files are causing the messages?

bencroker avatar Nov 05 '20 19:11 bencroker

This should be fixed in an update here. Can you show us which classes/files are causing the messages?

All of them: Class modules\custommodule\migrations Class modules\custommodule\records Class modules\custommodule\models Class modules\custommodule\variables Class modules\custommodule\assetbundles Class modules\custommodule\assetbundles Class modules\custommodule\assetbundles Class modules\custommodule\fields Class modules\custommodule\jobs Class modules\custommodule\twigextensions Class modules\custommodule\controllers Class modules\custommodule\controllers Class modules\custommodule\services Class modules\custommodule\widgets Class modules\custommodule\console Class modules\custommodule\CustomModule

kevinmu17 avatar Jan 08 '21 10:01 kevinmu17

Okay found the issue: in the composer.json you need these lines

  "autoload": {
    "psr-4": {
      "modules\\custommodule\\": "modules/custommodule/src"
    }
  },

beware of the trailing \, i overlooked them and was searching for hours :)

kevinmu17 avatar Jan 08 '21 10:01 kevinmu17

That should already be documented in the module's README.md file: https://github.com/nystudio107/generator-craftplugin/blob/master/app/templates/module_api_version_3_0/_README.md#installation

bencroker avatar Jan 11 '21 08:01 bencroker