safaricom / mpesa-php-sdk

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

added symphony Dotenv component package support for non-symphony and … #31

Closed ngarawakimani closed 5 years ago

ngarawakimani commented 5 years ago

This is a solution to issue number 7 (Fatal error: Call to undefined function Safaricom\Mpesa\env() in env() error.)

This error occurs when someone is not using laravel or a symphony based framework

We need to include symphony Dotenv component as a package and the declare an env() method like laravel does. Fixes #7 @KipchirchirIan @himanshupatel95

mossey commented 5 years ago

Brilliant work @ngarawakimani.

ngarawakimani commented 5 years ago

Thank you @mossey

Alecckie commented 5 years ago

Guys, something is not right somewhere. I did all that but still getting the same error Call to undefined function Safaricom\Mpesa\env() Below is my sample .env file Capture

Below is my symfony package (2.7...) inside vendor Capture

Below is a screenshot of my Mpesa.php Capture

I dont know where I'm going wrong...kindly help. Seems like the symfony is not loading or something.

ngarawakimani commented 5 years ago

You are not supposed to touch that file, just make your own index.php and then add require '../vendor/autoload.php';

ngarawakimani commented 5 years ago

Am gonna add an example folder later on to show exactly how to use this package especially if you do not use symphony based frameworks.

Alecckie commented 5 years ago

I will appreciate ... @ngarawakimani