Component Deployment Through Composer for Magento 2

Magento 2 allow package based deployment of the extension. You can register your extension in the marketplace or you can create your own repository URL for deployments.

One of the ways is through a private packagist network where you can list all your repositories at one location. Users can use them by accessing that URL or through GIT or VCS system.

Steps to follow to deploy extension through git:

Type: magento2-module

  1. If we are deploying magento2 module which doesn’t need to be copied from vendor directory to app/code/[vendorname]/[extensionname]. Then we can use this type of composer.json
  2. Upload the extension to any of git repo such as bitbucket (private) or GitHub(public) or packagist
  3. The git repo which needs to be deployed is recommended to be master and have released managed through tags in the particular git interface
  4. The tag version should be same as the version mentioned in the composer.json file of your package.

Type: magento2-component

  1. If we are deploying magento2 component which needs some interaction with the magneto component and we need to access root directories to place our customer file then composer json will be in root
  2. Upload the extension to any of git repo such as bitbucket (private) or GitHub(public) or packagist
  3. The extra keyword plays a big role here. This helps the composer to know where the files need to be placed after the download is taken place. It maps the folders and files accordingly.
  4. The git repo which needs to be deployed is recommended to be master and have released managed through tags in the particular git interface
  5. The tag version should be same as the version mentioned in the composer.json file of your package.

Customers Integration:

  1. Customer needs to register the repository URL from where the extension will be downloaded.
  2. Then fire following command
  3. composer require vendor/package [version number]
  4. Eg: composer require vendor/package 1.0.1
  5. The extension/component will be installed in the Magento vendor/ or root path.