I wish to read and use information stored in my env.php
. Is there an entity that I can use to achieve this?
Any tips are highly appreciated. Thanks.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI wish to read and use information stored in my env.php
. Is there an entity that I can use to achieve this?
Any tips are highly appreciated. Thanks.
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'));
For default values, see Magento's deployment configuration.