CodeIgniter Forums

Full Version: Including and Requiring files.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]AlexandrosG[/eluser]
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!!

El Forum

[eluser]RobertSF[/eluser]
Do you have your folders set up more or less like this?
Code:
|
+-- 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:

El Forum

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

El Forum

[eluser]AlexandrosG[/eluser]
You are right!

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