Name your component
Contents
- Overview of naming a component
- Prerequisites
- Add the component鈥檚
module.xmlfile - Add the components
composer.jsonfile
Overview of naming a component
You give a name to your component in its composer.json and module.xml files. These files also contain other required configuration parameters, such as the module鈥檚 schema version.
Prerequisites
Before you continue, make sure you have completed all of the following tasks:
- Created a file structure
- Created the the configuration files you鈥檒l need
- Registered your component
Add the component鈥檚 module.xml file
Declare the component itself by adding a module.xml file in the /etc folder of your component.
A component declares itself (that is, defines its name and existence) in the module.xml file, located in the Magento install directory at <ComponentName>/etc/.
The smallest working module.xml file would look something like this:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_ComponentName" setup_version="2.0.0"/>
</config>
鈥here name is the name of your component, and setup_version is your module鈥檚 database schema version. Both of these attributes are required.
Add the components composer.json file
composer.json provides a component name and also specifies component dependencies.
A sample follows:
{
"name": "your-name/module-Acme",
"description": "Test component for Magento 2",
"require": {
"php": "~5.5.0|~5.6.0",
"magento/module-store": "1.0.0-beta",
"magento/module-catalog": "1.0.0-beta",
"magento/module-catalog-inventory": "1.0.0-beta",
"magento/module-ui": "self.version",
"magento/magento-composer-installer": "*"
},
"suggest": {
"magento/module-webapi": "1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Magento\\CatalogImportExport\\": ""
}
}
}where:
name鈥攊s the name of your component.description鈥攊s a concise explanation of your component鈥檚 purpose.require鈥攍ists any components your component depends on.suggest鈥攍ists soft dependencies. The component can operate without them, but if the components are active, this component might impact their functionality.Suggestdoes not affect component load order.type鈥攄etermines what the Magento component type. Choose from magento2-theme, magento2-language, or magento2-module.version鈥攍ists the version of the component.license鈥攍ists applicable licenses that apply to your component.autoload鈥攊nstructs composer to load the specified files.
Magento does not currently support the path repository.
Find us on