Close [x]

Composer integration

Edit this page on GitHub

Composer integration

Composer is a dependency manager for PHP. Magento 2 uses Composer to package components and product editions. Some third party components that the Magento system uses may be actually not present in the code base. Instead, they are listed as dependencies in the root composer.json file.

Overview of composer.json files

Certain Magento components and product editions are represented with composer.json files.

Type of composer.json Location Naming convention Composer type Notes
Root composer.json
magento/magento2ce
project
This is the main composer.json file. Magento uses this file to declare dependencies on third-party components. This file is used as a template for any other root composer.json files
CE project composer.json
magento/project-community-edition
project
This file represents the Magento Community Edition project. The package only includes the composer.json, which declares the dependencies on the magento product as well as the class autoloader. This can be used by Magento system integrators to deploy Magento using Composer.
CE product composer.json
magento/product-community-edition
metapackage
This file represents Magento Community Edition product. The package only includes composer.json that declares the dependencies on magento components (modules, themes, and so on) and third-party components. This can be used by Magento system integrators to deploy Magento using Composer.
module app/code/Magento/<Module>/composer.json
magento/module-catalog-inventory
magento/module-checkout
magento2-module
The fully qualified module name, broken down into vendor, with the rest of the words as suffixes. The "module" prefix is mandatory to disambiguate from other types (for example, Magento_Backend module versus Magento/backend theme).
theme app/design/<area>/Magento/<theme>/composer.json
magento/theme-frontend-blank
magento/theme-adminhtml-backend
magento2-theme
Themes belong to areas, so the area name has to be the first suffix
language packages app/i18n/magento/<language>/composer.json
magento/language-en_gb
magento/language-de_de
magento2-language
The language identifier must be lowercase.
Magento framework lib/internal/Magento/Framework/composer.json
magento/framework
n/a Used only by the framework

Magento does not currently support the path repository.

Naming conventions

The namespace of Composer packages is global within a package repository (such as packagist.org). The Composer specification requires that a package name use the format:

<vendor_name>/<package_name>

As a result, vendors of different packages are distinguished, and there is a low risk of overlapping (unless different vendors names themselves exactly the same). All letters in the name must be lowercase. Therefore, the format for package names released by Magento Inc is:

magento/*

The package name is up to the vendor (as long as it is lowercase). If this name is meant to consist of multiple words, the Composer specification recommends separating them with dash. The convention for Magento package names is this:

magento/<type-prefix>-<suffix>[-<suffix>]...

Where:

type-prefix is a type of component in a Magento-specific domain.

suffix is anything that allows distinguishing/disambiguating the component within that type.

Magento-specific package types

Each Magento component can be categorized into one of the types listed in the preceding table. If any component does not fit into a specific category, it can be generalized to magento-component.

Having an identifier type for each component allows the system to marshal the directories and files of each component to the correct locations, based on the Magento 2 directory structure.

Composer Binary Location

Magento鈥檚 bin/magento script uses composer from the vendor/composer directory in your Magento 2 installation, not your globally installed composer. Keep this in mind while customizing or updating composer or troubleshooting Composer issues while working with Magento 2.