
codeigniter
Code Igniter
- A Nice PHP Framework with low memmory footprint
- MVC (Model View Controller) Design
- Easy to learn and test
- Suitable for Most hosting accounts
- Base of Expression Engine 2
- Deep Documentation and Tutorials
How To Begin in Fedora 11.
In Fedora 11 the Apache server is coming as pre-loaded . If you installed the servers it is there.
If not install httpd packages by using
yum install httpd
or from fedora 11 DVD – Or Use the Add- Or remove software utility
If not running go to root and
service httpd start
The Default path for web files is /var/www/html
This is the path go when you type http://localhost/some-name . The request go to some-name/index.php or index.html
Begin CodeIgniter
First Download the latest release from www.codeigniter.com
The package come with its detailed user_guide
Untar to the /var/www/html directory.
It will give you two Directories system and user_guide
like
/var/www/html/some-folder/user_guide and
/var/www/html/some-folder/system
point your broswer (usually it is firefox 3) to
http://localhost/some-folder
You will greeted with codeigniter welcome Page.
That is it CodeIgniter Installed.
point browser to
http://localhost/some-folder/user_guide
You will get a detailed documentation part of codeigniter.
First Application
the system folder contain two parts

The directory structure
codeigniter system files and your application files
the application files is in application directory
This is the directory where you work with.
System
System folder contains all the framework files including framework build class libraries, fonts, database configuration for your system, languages files, helper classes etc.
Application
Projects files will place inside this folder. Projects controller class will be placed inside Controller,
projects database related class will be placed inside Model,
Template based work will place inside Views folder.
User defined libraries will be place inside libraries.
Projects oriented application configuration will be done inside config folder such as autoload, routes etc.
Starting a Codeigniter Project
Configuration
open file with your favourite editor like netbeans,blue-fish,gedit,komodo,vim,kwrite or anything ….
/var/www/html/some-folder/system/application/config/config.php
This is the CodeIgniter Configuration file then change this line to
1: $config['base_url'] = "http://example.com/ ";
to
1: $config['base_url'] = "http://your/project/address";
like
1: $config['base_url'] = "http://localhost/some-folder";
Autoload
Autoload the entire user defined or framework based class when you create an instance of a class.
So you can defined some default class which will load when the projects run.
Like we need the database (to connect your application to a database like mysql or postgresql) class library and
session class library (maintain sesson variables like username password ipaddress etc) every time,
so you can defined them inside autoload.php file.
$autoload['libraries'] = array('database', 'session');
Also you can auto load helpes like url(to create base url , validate url etc) file (upload files, file types etc ..)
$autoload['helper'] = array('url', 'file');
If you added the database library in autoload dont forget to configure your database connections in the database.php file.
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "test";
$db['default']['password'] = "test";
$db['default']['database'] = "mydb";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
these are the essential lines to be configured
Set Default Controller for project
the default controller serve all default index.php requests.
for that open the routs.php in the config folder
$route['default_controller'] = "welcome";
to
$route['default_controller'] = "mycontroller";
The mycontroller.php must be in the controllers directory and the mymodel.php in the models directory.
Set .htaccess file
The .htaccess file help to avoid the index.php in the url line like
http://localhost/some-folder/index.php/mycontroller to
http://localhost/some-folder/mycontroller
in the .htaccess file you can add
<IfModule mod_rewrite.c>
2: RewriteEngine On
3: RewriteBase /YOUR_PROJECT_ROOT_FOLDER_LOC
4: RewriteCond %{REQUEST_FILENAME} !-f
5: RewriteCond %{REQUEST_FILENAME} !-d
6: RewriteRule ^(.*)$ index.php/$1 [L]
7: </IfModule>
8:
9: <IfModule !mod_rewrite.c>
10: # If we don't have mod_rewrite installed, all 404's
11: # can be sent to index.php, and everything works as normal.
12: # Submitted by: ElliotHaughin
13: ErrorDocument 404 /index.php
14: </IfModule>
These lines
if the mod_rewrite module is not loaded into httpd server then this will not work
you can include this by change this line in /etc/httpd/conf/httpd.conf
1: #LoadModule rewrite_module modules/mod_rewrite.so
uncomment this line by deleting the # mark in the beginning.
in line no 320 if it is like#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
then change to
AllowOverride All
then save and clode this fie. Make a backup copy of this file before editing will avoid any problems.
restart the httpd service by
service httpd restart
then point your browser to your codeigniter directory.
your default controller mycontroller will load with out hasle
put an echo to test that .
Have fun with CodeIgniter.
There is a stunnig application buit with codeigniter called open-blog. Download that and examine the code for extended experience. In that Matchbox library is used to make modules

No related posts.