CodeIgniter Forums
Global Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Global Library (/showthread.php?tid=16650)



Global Library - El Forum - 03-12-2009

[eluser]newsun[/eluser]
I am looking to create some libraries to use across multiple applications and wondered if I can just create them in the CI->library directory like creating an app specific one?


Global Library - El Forum - 03-12-2009

[eluser]jacobc[/eluser]
you can create them in the CI library directory...

I would tend to download the latest CI, and implement some libraries that I want to use in all my applications.

Then when you want to start a new app, instead of a fresh CI install... you use your CI + custom libraries instead.

If you have a server that hosts many of your apps, you might be able to do some symbolic linking to you own library folder that is used in all the apps.


Global Library - El Forum - 03-13-2009

[eluser]Michael;[/eluser]
Greets Newsun,

There are 3 different places you can store libraries ... /application/libraries, /system/libraries, or /system/libraries/folder_name

The last option allows you to use multiple applications that use the same system folder and still have access to global or common libraries. Personally, I choose not to store them in /system/libraries/ because it makes upgrading just a tad bit more difficult; so I tend to use /system/libraries/common/ as my global hot spot.

Michael


Global Library - El Forum - 03-15-2009

[eluser]newsun[/eluser]
How do you load the library in the /system/libraries/common/ directory or even in a sub-directory within?


Global Library - El Forum - 03-16-2009

[eluser]Michael;[/eluser]
Greets,

$this->load->library('common/lib_name');

Simply, add the sub-folder name before the library name.

Michael


Global Library - El Forum - 03-16-2009

[eluser]jedd[/eluser]
My money is on application/libraries - as it's part of the 'user' section of the CI directory structure. That is, the bit that you own and that CI upgrades tend to not step on the toes of.

Added bonus, you don't have to specify a path to load 'em.


Global Library - El Forum - 03-16-2009

[eluser]Michael;[/eluser]
Jedd,

If you do not need to share a library across multiple applications then applications/libraries is the correct location, however that is not the case which we are discussing here.

Michael


Global Library - El Forum - 03-16-2009

[eluser]jedd[/eluser]
Ah, my mistake, sorry. I misinterpreted the original post as how to use libraries across multiple CI application instances, rather than using libraries across multiple applications living within one CI instance. (I keep forgetting people actually do that! Wink)


Global Library - El Forum - 03-16-2009

[eluser]Michael;[/eluser]
Jedd,

Is quite alright.

Michael