1

Is their any way we can get env variables values in custom script ?

1 Answer 1

0

Have a look at \Magento\Framework\App\DeploymentConfig:

Inject a deployment config object of \Magento\Framework\App\DeploymentConfig in your code and then retrieve the value like this:

$deploymentConfig->get('db/connection/default/host');

For Example:

$deploymentConfig->get('your/custom/value');

Courtesy: Magento 2. Retrieve information from env.php programmatically

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.