How do I include external Libraries in CodeIgniter?

后端 未结 4 1907
情深已故
情深已故 2020-12-15 17:37

I\'m new to codeigniter, and I\'m trying to integrate amazon\'s FPS into my page. There are a bunch of libraries and models that go with Amazon FPS, which I would need inclu

相关标签:
4条回答
  • 2020-12-15 18:05

    Peng Kong of a3m http://code.google.com/p/a3m/ has a nice way of doing it with plugins:

    Example twitter_pi.php

    require_once(APPPATH.'modules/account/plugins/libraries/jmathai-twitter-async/EpiCurl.php'); require_once(APPPATH.'modules/account/plugins/libraries/jmathai-twitter-async/EpiOAuth.php'); require_once(APPPATH.'modules/account/plugins/libraries/jmathai-twitter-async/EpiTwitter.php');

    /* End of file twitter_pi.php / / Location: ./system/application/modules/account/plugins/twitter_pi.php */

    In controller

    $this->load->plugin('twitter'); $twitterObj = new EpiTwitter($this->config->item('twitter_consumer_key'), $this->config->item('twitter_consumer_secret'));

    There is one problem with this in Codeigniter 2.0 there are no plugins

    0 讨论(0)
  • 2020-12-15 18:12

    There is nothing stopping you from directly including classes and working with them however you would in a vanilla PHP setup. If it works in PHP it will work in CodeIgniter.

    include(APPPATH.'libraries/Amazon/FPS/Interface.php');
    
    0 讨论(0)
  • 2020-12-15 18:21

    Oh yes codeigniter is nice and has also support for many librarys please have a look here http://www.haughin.com/code/ Include the Amazon service like this $this->load->library('s3');

    0 讨论(0)
  • 2020-12-15 18:22

    @user3526 Note that $this->load->library('classname') will create an instance of that loaded class, not just file (class) include.

    0 讨论(0)
提交回复
热议问题