safaricom / mpesa-php-sdk

A PHP sdk for the new Mpesa RESTful APIs
188 stars 211 forks source link

load environment configs from database #34

Open Nickbahson opened 5 years ago

Nickbahson commented 5 years ago

Would be great if there was a way to set the environment configs on every request, like load the required values from a database before calling e.g. like //Example `$mpesa->setConfigs( [ MPESA_CONSUMER_KEY= [consumer key] MPESA_CONSUMER_SECRET=[consumer secret] MPESA_ENV=[live or sandbox] ]; );

$mpesa->STKPushSimulation();`

Davisonpro commented 5 years ago

I second you on this. They should just do away with the .env file. I have to edit their repository before i use it. Please work on this

ngarawakimani commented 5 years ago

I second you on this. They should just do away with the .env file. I have to edit their repository before i use it. Please work on this

why do you have to edit the repo? just create a .env file and paste your mpesa configs there.

Davisonpro commented 5 years ago

I agree with that. The problem comes when you have to explain this to a client who wants things done and he/she understands nothing about accessing and editing files on a server. It would be better if I just add a section to edit the configuration on their website and for Mpesa SDK to pull the configuration from the database. And using the env method will not support that

It's a design practice for sdks.

ngarawakimani commented 5 years ago

so you guys want to store configs in a database?

Davisonpro commented 5 years ago

Not necessarily. I think it would be great if you you went with @Nickbahson option

mossey commented 5 years ago

On it guys. I Will add this option

josiahke commented 5 years ago

the best way is to add a config that can override the default env

Nickbahson commented 4 years ago

@josiahke , you don't have to override the default .env file unless you have to.