ReynierPM
ReynierPM

Reputation: 18660

Integrate REST API SDK Php for PayPal with Code Igniter project

I need to use rest-api-sdk-php in Code Igniter project. I read the docs and first problem is Code Igniter don't use composer approach so I have downloaded the library as a .zip file and put inside library folder. Now the problem is that the SDK uses OOP approach and Code Igniter doesn't or not at all then how do I integrate the library to my project?

Get errors while trying to use the library

I'm trying to use the library in my module (PyroCMS module) and I did as follow:

include SHARED_ADDONPATH . 'libraries/paypal/config.php';
include SHARED_ADDONPATH . 'libraries/paypal/autoload.php';

$PayPal = new \angelleye\PayPal\Adaptive($PayPalConfig);

But I get this error:

Fatal error: Class 'angelleye\PayPal\Adaptive' not found in /var/www/html/alomicuba/addons/shared_addons/modules/payment/controllers/payment.php on line 51

So I think autoloading isn't working, any help?

Upvotes: 0

Views: 5275

Answers (1)

Drew Angell
Drew Angell

Reputation: 26036

CodeIgniter is indeed an OOP platform. Not sure why you would say otherwise..?? You can use Composer with CodeIgniter, too.

I would recommend using the Classic API instead of REST, though. The REST API is much newer and not nearly as mature as the classic API. You'll probably run into things you want to do later that REST simply doesn't provide yet, and then you'll need classic anyway.

On that note, I have a PayPal library specific to CodeIgniter you might be interested in. It's slightly out-dated because I have stopped maintaining that so that I can focus on my general PayPal PHP library, which has been updated to work with (or without) Composer. Again, though, it could be used in CodeIgniter, or you could just use the CI specific library, which does contain pretty much everything the classic API's have to offer.

So, if you're familiar with CodeIgniter libraries already I'd probably recommend just going with that one. I would definitely recommend getting familiar with Composer, though, and eventually making the jump from CI to Laravel.

Upvotes: 3

Related Questions