Package a component
Overview of packaging
The Magento application uses Composer packages to distribute, install, and upgrade components in an application instance.
To package a component, you must:
- Create a Magento Composer file (
- Register the component using
Package and publish your component.
Use our validation tool to check your package before you distribute it.
Create a Magento Composer file
composer.json file defines the name, requirements, version, and other basic information about the component. This file must be placed in the root directory of the module.
composer.json uses Composer’s generic schema, with the following restrictions:
||A fully-qualified component name, in the format
||For modules, this value must be set to
||Specify necessary information to be loaded, such as registration.php. For more information, see Autoloading from Composer.|
The following table discusses the component types that Magento Marketplace supports. The composer
type column in the following table specifies the value of the
type field you must add to
composer.json for that type of component.
Technically, a Composer package type, not a Magento component type. A metapackage consists of only a
For example, both Magento Open Source and Magento Commerce are metapackages.
|Module||magento2-module||Code that modifies Magento application behavior. You can upload a single module to the Magento Marketplace or your module can be dependent on some parent package.|
|Theme||magento2-theme||Code that modifies the look and feel of the storefront or Magento Admin.|
|Language package||magento2-language||Translations for the storefront or Admin.|
Metapackages allow you to group an extension that consists of multiple packages into a cohesive unit. This works exactly as described in standard composer.json documentation. If you have an extension that uses more than one package you must use a metapackage as the root package. Otherwise you should not use metapackage. A metapackage that you submit to Magento Marketplace should be a .zip file containing only the metapackage
We recommend metapackages refer to specific component versions. Do not use wildcards to represent version ranges.
The following example is a
composer.json for a metapackage:
Sample composer.json file
The following example is a
composer.json file for a module:
Package and publish your extension
Create a package of your extension by performing a zip operation on the directory with your extension (excluding unnecessary directories). For example:
zip -r vendor-name_package-name-1.0.0.zip package-path/ -x 'package-path/.git/*'
Use alphanumeric characters for the package filename with dashes to separate words. Do not use whitespaces.
Magento can retrieve your extension package from any valid GitHub URL.
Third party repositories are supported.
Hosting on GitHub and Packagist
Prerequisite: git must be set up on your machine.
- Navigate to your component directory, with the
composer.jsonfile in the root, and make it a new git repository. See the GitHub documentation for details.
- When you have committed and pushed your component to your GitHub repository, you can either:
- Use Composer to refer to it directly, or
- Use the following steps to refer to the package through Packagist.
- Register an account at packagist.org.
- Click the Submit Package button and paste your GitHub repository link. Packagist automatically gathers the information from the component’s
composer.jsonfile and link it to the GitHub repository, allowing you to reference the package as
vendor/modulewithout any additional repository information, because this is required solely using GitHub.
Hosting on a private repository
If you use the Setup Wizard, you must use the Magento Marketplace repository. A private repository can be used for development or private code but installation must be done with a command line interface (you can install a that specifies a private repository only with a command line installation).
- Set up your own Composer packaging repository using a system such as Satis or Toran.
- Create the package in a way similar to the described above.
- Submit/register the package on your own repository. For example, it can be hosted as a reference to a code repository or submitted as a zip-archive.
- To use the private packaging repository in a project, add the following to your
All packages on the private repository can now be referenced within the