nystudio107 / generator-craftplugin

generator-craftplugin is a Yeoman generator for Craft CMS plugins
MIT License
74 stars 30 forks source link

Composer 2.0 type warnings #104

Open loqus opened 3 years ago

loqus commented 3 years ago

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

bencroker commented 3 years ago

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

kevinmu17 commented 3 years ago

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 commented 3 years ago

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 :)

bencroker commented 3 years ago

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