This is the way to go:
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Amit\\SamplePage\\": ""
}
}
The map function in Composer:
"extra": {
"map": [
[
"*",
"Amit/SamplePage"
]
]
}
forces tethe extension to be installed in app/codeapp/code
. This was used in older beta's of Magento 2. Although this will work, it's not the way Magento loads extensions anymore. If you do not use the map function the extension will be installed in the vendor folder, as it should be.
Registration.phpregistration.php
defines the type: theme or extension and registers your theme/extension in Magento 2.
The composer.jsoncomposer.json
file is added so the extension can be loaded via composerComposer. It also handles the autoloading for your extension.