Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter helpful hints

I thought it might be a good idea to post some of our most helpful hints for using the CodeIgniter framework:

Hint 1
I prefer to move the application directory out of the CI system directory for three reasons:

1. Upgrading the CI Core doesn't destroy my application configuration.
2. During development its easier to find my stuff and ignore the CI Core files.
3. CI works ok like this with no modifications.

(IMO Ellislab should take note here and change this!)
No other developers recommend you put application files in the system directory.

Hint 2
Create an autoloaded application.php config file and use it to override the default CI config settings plus add your own custom settings.

This idea would work especially well if you create two config files using one for development server settings and the other for your production server settings.

The only file you need to change is the autoload.php config file setting, and again CI upgrades won't overwrite your custom files.

Fully agree with the Hint 1, its the first thing we do as well, but for matchbox 'modules' we also structure it this way for easier access although I am considering putting back into the application dir

o root
- o system
- o application
- o modules
- o css
- o images
- o js

yes i always move things
my prefered structuer is
/usr/local/CodeIgniter1.5.4/system/ - CodeIgniter System files
/usr/local/CodeIgniter1.6.0/system/ - CodeIgniter System files

/home/user/apps/myapp/ - application folder of the app
/home/user/apps/anotherapp/ - another application folder if required for seperate app

/home/user/wwwroot/ - where the index.php and any img, css, js files go in appropriate folders

Gives great separation this way.
Multiple sites can use a single version of CI core files
Each user can have their own app files

Very good idea there tonanbarbarian, shame that I have had open_basedir turned on Sad

[eluser]Référencement Google[/eluser]
I join you on the Hint1, moving the application folder out of the system folder is the first thing that I do when starting a new CI application.

About Hint2, it's not a bad idea, but that depend on people, it not suits everybody's needs.

I'm not against moving the application directory out off the system directory but i find it useful that the framework only adds one folder and a bootstrap file to the root when i have to rewrite websites. Most of the time the root is polluted with the production site directories and files and other things that were added at some time (and they curse the developer who wants to replace those).

If the application directory is going to be placed outside the system folder out of the box i would like to see the directory names prefixed.

The application directory should be placed out of the root anyway, just like the system directory. Only files in the webroot should be index.php and a .htaccess file. Images, js and css excepted, you may take your own approach there. This should be in the user guide, though.

CI should promote this more and for starters move the application directory out of the system directory. This will make more clear on how to have one system directory for multiple sites.

thanks for the tips! as someone new to codeigniter (and relatively new to php frameworks) i hope this thread continues.

Glad it helped, I hope others continue to post Helpful Hints also.


If you need to set any other variables that are site wide you can just place them into your application/config.php file eg.

$config['server_path'] = "/home/user/account/site/";

You can then access it as the following where-ever you please Smile


Theme © iAndrew 2016 - Forum software by © MyBB