This Composer plugin allows Moodle plugins to be installed into the correct locations within the Moodle directory.
Your plugin should have a composer.json which defines the following fields:
namein the formatmoodle-[plugintype]_[pluginname]typeofmoodle-[plugintype].
You should depend upon this plugin:
composer require moodle/composer-installer