Monday, July 18, 2011

CodeIgniter - Routing


Implementation of the routing is the interesting idea to manage short URL re-writing.

Way to implement the routing :
Just open the application/config/routes.php, insert the line at the end of the file.

1) if you want that URL would be
here, work is the controller name and holiday is the data that would be dynamically changed. So, to implement this just write like this:
$route['work/(:any)'] = 'work/work_detail/$1';
here (:any) = would accept any type of argument,
work/work_detail : class/function relationship
$1 : argument passed

class Implementation:

class Work extends CI_Controller{

function __construct(){
function work_detail($arg){
echo $arg; //would return holiday

2) If your URL is, where service is controller and data would dynamic changed,
but client requirement is URL : only. then you have to manager class/function relationship implicitly.

open routes.php and insert line at the end of the file.
$route['^(?!work|home).*'] = 'page/info/$1';

here, i used regular expression to bypass control from work,home class, means url : and not there then it would follow page class.

i.e. if URL : called then specific routing will transfer control to the page/info :: class/function relationship,

it will help in short URL re-writing cases.
Class Page extends CI_Controller{
function __construct(){

function info($arg){
echo $arg; //would give data

Bye everybody...

CodeIgniter - an open source Web Application Framework

Hi Everybody,

From last 3 month, i was working on codeIgniter Framework. And i found its very interesting tool to manage MVC structure.

I start my work on version 2.0.2, it's the latest version of CI. Here many new feature introduced like :
# Support for PHP 4 is gone, PHP 5.1 is now a requirement.
# CSRF Protection built into the form helper
# Drivers
# Application Packages
# Scaffolding, having been deprecated for a number of versions, has been removed.
# Removed the deprecated Validation Class.
# Plugins have been removed, in favor of Helpers.
# Added routing overrides to the main index.php file, enabling the normal routing to be overridden on a per “index” file basis.
# Added $route[‘404_override’] to allow 404 pages to be handled by controllers.

which are not available in CI older version i.e. 1.7.x versions.

CI has very good User Guide that provide methods of creating web application with best implementation way.
URL of User-Guid:

At the end i like it so much because of its light weight, good user guid and good support on bug fixing.

Bye :)