Open jaymoh opened 3 years ago
@jaymoh , this isn't a bug, it is actually the expected behavior.
When you run config:cache
on a laravel app it caches the app configuration to improve performance.
Once the configuration has been cached, the .env
file will not be loaded and calls to the env()
helper will only return system-level environment variables.
A configuration management best practice is to use the env()
helper only inside config files. That way your environment variables will be cached as you expect. i.e
add an mpesa.php
config file and in it read the values with the env()
helper
Then update your code to reference the config values with the config()
helper
@vino-jasuba yes, actually the problem is that this Mpesa package reads from .env file
check out #25. I doubt it'll ever be merged in but looks like it addresses your problem.
Maybe fork the repo and reference it as a private package?
When using this SDK inside a laravel project, the package fails to read the env variables if you run the config:cache command.
It's only able to pick the MPESA secret and keys after running config:clear Which is weird because we need to be able to cache our configurations to improve on performance.
I have used the package in a couple of projects, great work. I always run config:cache and it messes me up big time.