0

currently I have hardcoded my API token in my controller, Need to make it configurable so that it can be configured when the code is deployed in production.

So how can I store it on Magento variable from Magento cloud environment?

I see the variables section in configure environment in https://us-3.magento.cloud

If I set my customer variable there, then how can I access it in my controller file.

And what's with so many variables types in Magento and which should i use.

https://devdocs.magento.com/guides/v2.3/cloud/env/variables-intro.html

1 Answer 1

1

Magento has talked about all environment variables in the link whichever you have shared.

I hope, you want to save the API token and fetch it on controller to trigger web service call right. If so, you can create simple store configuration option in your module system.xml file which will allow store admin to set the token whenever you want and you can easily change also without doing any deployment and all.

3
  • How to do it can you elaborate ?
    – summu
    Mar 24, 2019 at 16:45
  • 1
    I agree with @thamo Also, you can add a variable with env: prefix on the Magento Cloud. For example: env:CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME = MY STORE This variable will rewrite configuration from the Admin Panel and lock it, so you cannot change it via the Admin Panel.
    – BaDos
    Mar 26, 2019 at 15:26
  • @summu - BaDos has shared the more relevant way. As you are using cloud env , please use env variable for keeping the token.
    – Thamo
    Mar 27, 2019 at 11:13

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.