- Synopsis
- Overview
- Install the sample module
- Add custom options to deployment configuration
- Tests
- Contributors
- License
Creating custom options is discussed in Add custom options to setup:config:set
.
Clone the magento2-samples repository using either the HTTPS or SSH protocols.
Create a directory for the sample module and copy magento2-samples/sample-module-custom-deployment-config
to it:
mkdir -p <your Magento install dir>/app/code/Magento/CustomDeploymentConfigExample
cp -R <magento2-samples clone dir>/sample-module-custom-deployment-config/* <your Magento install dir>/app/code/Magento/CustomDeploymentConfigExample
If you added the module to an existing Magento installation, run the following command:
php <your Magento install dir>/bin/magento setup:upgrade
Enter the following command:
php <your Magento install dir>/bin/magento --list
The following confirms you installed the module correctly:
example
example:custom-deployment-config:show Show custom deployment configuration option
To use the sample command:
cd <your Magento install dir>/bin
php magento example:custom-deployment-config:show
php magento setup:config:set --help
magento example:custom-deployment-config:show
displays the value assigned to the custom option defined in Magento\CustomDeploymentConfigExample\Setup\ConfigOptionsList
while magento setup:config:set --help
displays all options available for set.
-
Create class
ConfigOptionsList
in<module_dir>/Setup
that implementsMagento\Framework\Setup\ConfigOptionsListInterface
-
Implement required methods:
getOptions()
: Returns list of custom options that should be added to the deployment configurationcreateConfigData()
: Creates the required array structure to be stored in the deployment configurationvalidate()
: Validates option values
-
Clean the Magento cache.
-
Run
php <path to Magento root>/bin/magento setup:config:set --help
to make sure the custom option is present.
Unit tests could be found in the Test/Unit directory.
Magento Core team