dev-master
9999999-devHammer Config Manager
MIT
The Requires
- php ~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0
by Weidenhammer
Hammer Config Manager
composer require hammer/config-manager:dev-master
bin/magento module:enable Hammer_ConfigManager
bin/magento setup:upgrade
Set the environment you are working on (example: local, dev, stage, preprod, prod) using the following command, (*1)
bin/magento hammer:environment:set [local, dev, stage, preprod, prod]
, (*2)
This one create a new entry to env.php (app/etc/env.php), (*3)
'hammer_environment' => 'local'
, (*4)
that it's used by the Config Manager in order to know where to find the correct file with the information that correspond to each environment. Local configuration should be a config file in app/etc/custom_config/local/config.json, (*5)
For other environments (dev, stage, preprod and prod) the file should be located in app/etc/custom_config/config.json., (*6)
All these files contains the data for the values that change in each environment., (*7)
For example:, (*8)
{ "Hammer_PaymentSetup::paypal/wpp/api_username": "direct-facilitator_api1.testmerchant.com", "Hammer_PaymentSetup::paypal/wpp/api_password": "FOCQ5TD5JRNH8TDG", "Hammer_PaymentSetup::paypal/wpp/api_signature": "AFcWxV21C7fe9m3bPOFHRpSSRl31AOsbMi0t56rdj7bZ7m9EkAVQQ1gr", "Hammer_PaymentSetup::paypal/wpp/sandbox_flag": 1 }
To use this we should inject the dependencies like, (*9)
public function __construct( EncryptorInterface $encryptor, Config $config, \Hammer\ConfigManager\Helper\ConfigManager $configManager) { //var initialization }
after that we will be able to get the value like so:, (*10)
$sandboxFlag = $this->configManager->getProperty('Hammer_PaymentSetup::paypal/wpp/sandbox_flag');
, (*11)
Hammer Config Manager
MIT