CodeIgniter Forums
Including and Requiring files. - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Including and Requiring files. (/thread-59326.html)

Including and Requiring files. - El Forum - 09-21-2013

Hi! I have a PHP library with many PHP files inside the same folder. There is one 'master' file that i have to include and this file can 'include' (depending on the function called) other files of the library. The problem with including in CI is the path. When using relative paths include doesn't work.

Do i have to change every 'include' path in the library?
There has to be some other way!!

Including and Requiring files. - El Forum - 09-24-2013

Do you have your folders set up more or less like this?
+-- CI
  +-- application
    +-- controllers
    +-- models
    +-- views
  +-- system
+-- Your PHP library
Then you include your PHP library, but when your PHP library starts including its own files, it doesn't work because now the starting point for the relative path is CI, not the library.

Can you move your PHP library to your CI folder? On my system, at least, getcwd() returns "C:\Users\RobertSF\Apache\htdocs\ci"

Now that I think of it, that's going to put all the library files in your CI folder, but that's because the library designers put the 'master' file and all the other files at the same level.

Maybe someone else has a better idea. I'm still a noob. :red:

Including and Requiring files. - El Forum - 09-24-2013

why not put your folder in the application/libraries and loading it by [b]foldername/filename[\b]. hope this helps.

Including and Requiring files. - El Forum - 10-01-2013

You are right!

I have still not get used to CI's loading concept.
I use loding only for CI's libraries.
Thanks guys!