How to Create Extension Package in Magento 2?
-
29-09-2020 - |
Question
In Magento 1.x we are creating Extension Package from System
-> Magento Connect
-> Package Extensions
. After that we are going to publish the extension in Magento Connect.
I think it's an easy to understand and easy to create and publish.
In Magento 2.x how to create like above and publish the extension to MarketPlace (Magento Connect).
Could you please suggest me how to do it?
Solution
Let's say you have developped a module under app/code/Vendor/Module
, here is the procedure you have to follow:
Create a composer file
Go to app/code/Vendor/Module
and create the following composer.json
file:
{
"name": "vendor/module",
"description": "Description of your Magento 2 module",
"type": "magento2-module",
"version": "0.1.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"magento/framework": "~100.0.4"
},
"authors": [
{
"name": "Firstname Lastname",
"email": "email@address.com",
"homepage": "https://www.store.com/",
"role": "Developer"
}
],
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Vendor\\Module\\": ""
}
}
}
Zip the package
Using command line do the following:
cd /path/to/app/code/Vendor/Module
zip -r vendor_module-0.1.0.zip ./*
N.B.: this example is assuming that your module version (declared under app/code/Vendor/Module/etc/module.xml
is 0.1.0, please change the version in both the composer.json
and in the command that zips the package to match your version.
OTHER TIPS
To create extension package and how to publish it, check following source :
- http://devdocs.magento.com/guides/v2.0/extension-dev-guide/package/package_module.html
- http://docs.magento.com/marketplace/user_guide/getting-started.html
Hope it helps