1. Move application directory outside of the system folder
Application directory doesn’t require residing inside system directory all time.
You can move this anywhere according to your convenience.
So, you don’t need to dig deeper into the system directory every time to access a controller or model.
After moving the application directory, you can simply update the new path in “$application_folder” variable of the main index.php file. And another happy new is, if you put the application directory & the system directory in a same folder, you don’t need to change anything.
2. Remove ‘index.php’ in the URLs using htaccess
By default CodeIgniter includes the index.php file in your URLs. To create friendlier & search engine optimized URL, remove the ‘index.php’ from your URLs using htaccess. Add the below code in an htaccess file & upload to your server and it will remove the ‘index.php’ from URL.
RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
3. Use routes.php to remap or redirect URLs
Use regex pattern or wildcards with $route array to remap a URL to a new location.
Instead creating a function for each redirection, this will help you to save time & resources.
4. Use Autoload whenever required
Use $autoload array to load resources (libraries, helpers, plugins etc) rather than loading in each function.
If it is required for a specific controller only, then load them in the controller’s constructor method.
It you use $autoload for everything, it will slow down your site & affect perfomance, so use it whenever necessary.
5. Try to keep all configuration in the config directory
Instead setting configuration values in each function, you can use a separate file to include all config options.
For example, you can use a form_validation.php file under ‘application/config’ folder and you can keep all validation rules for the total application in a single array.
In this manner you can create a separate file for every library.
Initially it may take some extra time, but in the long run it will help you to save many hours.
6. Filter all user input before adding them to DB
If your application heavily depends on user input, then set $config['global_xss_filtering'] = TRUE in config.php file.
Don’t forget to filter & escape user input for better security.
7. Don’t use pure PHP, if there is a CI alternative
Before using any native PHP function or code, double check if there is any CI function is available.
CI functions are created to help you to decrease your workload & to increase performance.
Always when you use CI, use CI functions.
I found lots of questions in CI forum to request help to mix pure PHP with CI (especially for session)
People are unaware of easy CI functions to create a simple thing, they’re writing many lines of pure PHP & getting into problems.
Using pure PHP with CI is not a crime, but why should we waste our valuable time? Think.
8. Delete unnecessary libraries and helpers to save server space
Usually, We don’t use all the libraries and helpers in every application. But keeping them in the server requires more space and cause extra cost.
Once we complete our development, when we move to hosting server its better to delete unused libraries & helpers. It will help to reduce hosting space usage. But be careful & make sure before deleting any file that it is not used anywhere.
9. Create a library or helper for frequently using functions
Try to create a library or helper with all reusable functions to avoid repeated coding of the same thing over and over.
For example if we need to check for user authentication, instead checking their authenticity in every function and redirecting them to login page (if the user doesn’t have permission) we can create a logincheck() function in authentication library and can simply call the function to check for permission.
10. Avoid .php extension when loading views
When loading view files, avoid using .php extensions. It is not necessary to use, unless if you use different extension like .html etc.
And one more : Cache output files to decrease server load
Repeated requests to a function that returns the same results every time can cause unnecessary load on the server.
It can be easily avoided by using the CoedIgniter’s cache() function.
Caching all the pages has no meaning, if they are dynamic pages.
If you use dynamic pages like stock ticker then there is no meaning of caching. Because its value changes every minute & it can display wrong information to the users.
So, use output cache wisely.










looks nice :)
This is actually a nice a little list. Codeigniter is amazing!
wow :) Thanks
Thanks :)
CodeIgniter 1.7.1 Cheatsheet v2.0…
<p>Senthil Kumar from <a href="http://designfellow.com">DesignFellow</a> has just released a new version of his CodeIgniter Cheatsheet.</p>
<p>The new version can be found in his <a href="http://designfel…
CodeIgniter quick reference cheat sheet version 2.0 released…
The second version of the code igniter cheat sheet containing 2 sheets:
- Sheet-1 contains library functions with parameters (including cart library, which is not yet released officially by CodeIgniter but available in svn)
- Sheet-2 is for helpers fun…
Thank a lot :-))