Open jukwahewa opened 4 years ago
I suspect it should be this on line 10 of Mpesa.php
require 'vendor/autoload.php';
Or possibly something like Carbon.php does?
$dir = __DIR__.'/..';
if (!file_exists($dir.'/autoload.php')) {
$dir = __DIR__.'/../vendor';
}
if (!file_exists($dir.'/autoload.php')) {
$dir = __DIR__.'/../../..';
}
if (!file_exists($dir.'/autoload.php')) {
echo 'Autoload not found.';
exit(1);
}
require $dir.'/autoload.php';
Or ../../autoload.php ?
I'm attempting to use this with Laravel.
Lia
Or possibly something like Carbon.php does?
$dir = __DIR__.'/..'; if (!file_exists($dir.'/autoload.php')) { $dir = __DIR__.'/../vendor'; } if (!file_exists($dir.'/autoload.php')) { $dir = __DIR__.'/../../..'; } if (!file_exists($dir.'/autoload.php')) { echo 'Autoload not found.'; exit(1); } require $dir.'/autoload.php';
Or ../../autoload.php ?
I'm attempting to use this with Laravel.
I gave up on this MPESA SDK as the developer(s) never replied to my opened bug request. I ended up writing custom PHP code to interact with the API. Please see MPESA API guiding docs here: https://developer.safaricom.co.ke/APIs
I wish you luck and all the best with your integration.
Thanks @jukwahewa , I will probably be forced to do the same as this is not the only issue I have noticed with this code.
Certainly! Here’s a more polished version of your comment:
We encountered the same issue after deploying to Lambda, but we were able to resolve it with the following steps:
Relocated the Mpesa Class: We moved the Mpesa class from the vendor
directory to a new directory we created, packages/safaricom/mpesa
.
Updated the include_once
Statement: We modified the include_once
function in the Mpesa class to point to the new location:
include_once("vendor/autoload.php");
Updated composer.json
: We adjusted the autoload
section in composer.json
to include the new directory:
"autoload": {
"psr-4": {
"Safaricom\\Mpesa\\": "packages/safaricom/mpesa/"
}
}
After making these changes, everything worked as expected. Hope this helps!
Warning: include_once(../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/mpesa/src/Mpesa.php on line 10
I get this error message whenever I am trying to use your PHP SDK. I think this is a bug for your relative paths to composer autoload file. I have also run composer install but issue is still persistent.
I am using your PHP SDK version 1.0.8. Please help as it does not work out of the box and I am stuck on this error .
Thank you.