If you execute the config:cache command during your deployment process, you should be sure that you are only calling the .env function within your configuration files.
Once the configuration has been cached, the .env file will not be loaded and calls to the env function will return null.
Go to your config folder and update app.php.
Add your config object
Go to your terminal
Create a Laravel class by running
php artisan make:controller BlogController
On your created controller. i.e BlogController.php add the following.
What happened here?
We’ve used Config Laravel class
Created public $API_SECRETvariable
Created __constructor and set $this->API_SECRET to use Config::get('app.api_secret.key').
Created class function getAPISecret() to return $this->API_SECRET.
Result
FQD2duGaJwdryxEvSpt/OXFjkYvwIJz6vVBwEcxoIe0=
Thanks for reading and following along. I hope that this blog will give value to you at some point. Please feel free to reach out if you have any questions.