Include external library |
[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.
[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(){
[eluser]CroNiX[/eluser]
Only CORE CI classes get prefixed with CI_, not your own libraries or controllers...
[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
[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');
[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-gui...asses.html
[eluser]Mauricio de Abreu Antunes[/eluser]
^ Agreed! Classes with MY as prefix extend Controller or Model class. Code: class MY_Model extends CI_Model {};
[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');
[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() |
Welcome Guest, Not a member yet? Register Sign In |