Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended approach to combining raw PHP and Codeigniter

I'm building a web app using Codeigniter as my framework of choice. I have a 3rd party library that I am using to handle some OpenID authentication. The library is written in raw PHP (I've tried some of the OpenID libraries written for Codeigniter but I couldn't get any of them to really work how I wanted to).

What is the recommended approach for using this raw PHP library alongside my Codeigniter files? The library isn't all that big but I'd much prefer if there is a way I can just plug this library into my Codeigniter app because I am new to Codeigniter and I'd rather spend my time building my application then porting a library from raw PHP to Codeigniter if I don't have to.

Additional info: I have written several applications in raw PHP, but I am new to Codeigniter

like image 237
justinl Avatar asked Feb 21 '26 06:02

justinl


2 Answers

Is the library a class in a single file? The "Codeigniter Way" to handle this is to put it into your application/libraries directory. In CI call $this->load->library('MyLibraryName'); before you use it. (There are also ways to load your library automatically - see application/config/autoload.php)

like image 130
Mike C Avatar answered Feb 23 '26 22:02

Mike C


include 'wherever/it/is.php';

$foo = new Bar;

Magic! :)

like image 23
Phil Sturgeon Avatar answered Feb 23 '26 21:02

Phil Sturgeon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!