Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

laravel issue on config:cache #48

Open
jaymoh opened this issue Jul 30, 2021 · 3 comments
Open

laravel issue on config:cache #48

jaymoh opened this issue Jul 30, 2021 · 3 comments

Comments

@jaymoh
Copy link

jaymoh commented Jul 30, 2021

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.

@vino-jasuba
Copy link

@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

@jaymoh
Copy link
Author

jaymoh commented Jul 31, 2021

@vino-jasuba yes, actually the problem is that this Mpesa package reads from .env file

@vino-jasuba
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants