Include external library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Include external library (/showthread.php?tid=49644) |
Include external library - El Forum - 02-27-2012 [eluser]ephlodur[/eluser] Hello all, I would like to include PHPRtfLite in one of my project. I was wondering what is the best way to include that external lib in the CI Framework. Thanks for your help. Include external library - El Forum - 02-29-2012 [eluser]heenji[/eluser] you could try this steps: copy phprtflite's lib content to CI application/librarys/PHPRtfLite, create a PHPRTFLITE.php in application/librarys,it content like following: Code: <?php make a controller and method like this: Code: public function testrtf(){ Include external library - El Forum - 02-29-2012 [eluser]CroNiX[/eluser] Only CORE CI classes get prefixed with CI_, not your own libraries or controllers... Include external library - El Forum - 02-29-2012 [eluser]ephlodur[/eluser] thank you very much for your response.. so far I get Code: An Error Was Encountered I guess I need to adjust the path. For now this is my configuration I have downloaded the PHPrtfLite and unzip the content to application/libraries that mean the path to the lib directory is application/libraries/PHPRtfLite/lib. I'm not sure to what level the call in the controller should be pointing Code: $this->load->library('phprtflite'); Thanks a lot for your help Include external library - El Forum - 02-29-2012 [eluser]Mauricio de Abreu Antunes[/eluser] If your file is in libraries/ you really dont need another config. Just load like this: Code: $this->load->library('your_lib'); Include external library - El Forum - 02-29-2012 [eluser]CroNiX[/eluser] You also shouldn't use MY_ as a prefix unless you are extending a CI Core class. http://ellislab.com/codeigniter/user-guide/general/core_classes.html Include external library - El Forum - 02-29-2012 [eluser]Mauricio de Abreu Antunes[/eluser] ^ Agreed! Classes with MY as prefix extend Controller or Model class. Code: class MY_Model extends CI_Model {}; Include external library - El Forum - 02-29-2012 [eluser]ephlodur[/eluser] Thanks to all for your reply I have change the class name and the file name as below: file name PHPRtfLite.cpp Code: class PHPRtfLite Code: $this->load->library('phprtflite'); Include external library - El Forum - 03-01-2012 [eluser]ephlodur[/eluser] Hello heenji and all, Thanks a lot for your help. I have manage to load the class with minor changes to the file provided by heenji. The content of the "lib" directory for PHPRtfLite is located in application/libraries/PHPRtfLite the file below "PHPRtfLite.php" is located in the directory application/libraries. Code: <?php Code: public function testrtf() |