• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extends CI native library into a package

I'm developing a php application using CodeIgniter2, this application resides in:


This application has its own `My_Session` library (extending from native CI_Session library). Well, everything goes fine here. But, I want to create a Portal/Frontpage at the root directory, for this porpusee I have installed another CI2 application:

-community/ (here resides the another CI2 installation)

What I have tried to do is "share" the Session library from `community` to root using the method $this->load->add_package_path() from Loader class, as below:


The problem here is that the Loader class load the Session library from the root system instead package library (community/application/libraries). Did you know how can I deal with it? or if you know a another way to share the Session Library.

Here is where my session library resides:


Well, I got and this is the final snipped:

1. Add the package

2. Load the Session library from Root CI application

3. Load the library from the application package (cmommunity)
The magic here is that this class extends from Session class previously loaded at point 2.
$this->library('MY_Session', '', 'csession'); //rename the session to avoid name conflicts

Now, in my root application controllers I can do:

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.