[eluser]Dave Stewart[/eluser]
Hello,
New to the ways of CI, I'm aiming to adopt best practices and attain a high belt in CI-fu!
From what I can tell from the documentation, include is now effectively redundant because any classes or functions are loaded dynamically using $this->load->class/library/helper/etc().
But are there any situations where you would use include? For example your own external functions, or should I look at converting all my classes and functions to CI Libraries and Helpers?
Would I still use includes in views (as I saw someone else do), or should I let the controller handle everything, and only have plain old vanilla HTML in the view files?
Thanks for reading,
Dave
[eluser]Yash[/eluser]
yup agreed with xwero
[eluser]xwero[/eluser]
The way i work most of the time is to create a codeigniter directory somewhere above the public root and that directory hold the CI framework and all the application folders. Most of the application folders are named like the domain to make it easy on myself. The system directory is renamed to shared because i see the system as the whole of CI + application + public files.
In the shared library i create the directories models and views for files that can be used in several applications. I put libraries that can be used in several applications in the shared/libraries. this way i can benefit from the CI extending libraries functionality. Of course this is not possible with the extended libraries they have to be copied until CI makes it possible to change the paths.
So it's not really necessary to create a folder outside the system. Even your old sites could link to the shared|system/libraries folder files to keep the copying to a minimum.
[eluser]Dave Stewart[/eluser]
Thanks for the info. I'm sure it will become clearer as I start development proper.
With regards to moving the app folder (I must admit, I personally like this approach) how do I configure CI to know about this?
I had a look in the front controller file index.php and it looks like it should work (to just move the application directory up one level) as it's setting first a root-level application folder, then falling back to a system-level application folder... but when I run my controllers and views, variables are now longer bring passed from the controller to the view correctly.
Any clues!?
Thanks,
Dave
[eluser]xwero[/eluser]
You have to add the full path to the $application and $system variables in the index.php file.
i find it strange your variables are not passed on to your view because they don't need to know the paths.
[eluser]Dave Stewart[/eluser]
How do I handle local and remote locations?
Usually I detect the $_SERVER vars and do a switch/case from there.
It feels a bit dirty to be doing so much editing of the index.php file, but I guess it's only one file.
Cheers,
Dave