Presentation of codeigniter to understand the framework and easy to understand for beginners.Codeigniter is php framework easy to learn and useful for start into web devlopment.
2. Introduction To CodeIgniter
What is CodeIgniter ?
Why to use CodeIgniter ?
How CodeIgniter works ?
M-V-C Architecture in CodeIgniter
Clean URL in CodeIgniter
Installation of CodeIgniter
Folder Structure of CodeIgniter
First Step for Development
Basic application in CodeIgniter
3. What is CodeIgniter ?
CodeIgniter is a PHP MVC framework used for
developing web applications rapidly. Its goal is to
enable you to develop projects much faster than
you could.
if you were writing code from scratch, by providing
a rich set of libraries for commonly needed tasks
when its not necessary, CodeIgniter will help you
by providing collection of libraries for performing
various operations in your web application.
CodeIgniter lets you creatively focus on your
project by minimizing the amount of code needed
for a given task.
4. Why to use CodeIgniter ?
Small footprints
Loosely coupled
Open source
Blazing fast
Model-View-Controller based system
Fully featured database classes
Excellent Documentation
Well supported by an active community
Easy to configure
Packs a Punch
Extensible
6. M-V-C Architecture in
CodeIgniter
CodeIgniter is based on the Model-View-Controller
development pattern. MVC is a software approach
that separates application logic from presentation.
1. The Model represents your data structures.
Typically your model classes will contain functions
that help you retrieve, insert, and update
information in your database.
2. The View is the information that is being
presented to a user. A View will normally be a web
page.
3. The Controller serves as
an intermediary between the Model, the View, and
any other resources needed to process the HTTP
request and generate a web page.
7. Clean URL in CodeIgniter
The URLs generated by CodeIgniter are clean and
search-engine friendly. Rather than using the
standard “query string” approach to URLs that is
synonymous with dynamic systems, CodeIgniter
uses a segment based approach.
8. Installation of CodeIgniter
https://codeigniter.com/download
Install the CodeIgniter framework from the
given link.
Unzip the package.
Upload the CodeIgniter folders and files to
your server. Normally the index.php file will
be at your root.
10. First Step for Development
Give the name to the CodeIgniter folder which we
unzip.
Open the application/config/config.php file with a
text editor and set your base URL.
If you intend to use a database, open the
application/config/database.php file with a text
editor and set your database settings.
11. Load all the necessary stuff
CodeIgniter comes with an “Auto-load” feature that
permits libraries, helpers, and models to be initialized
automatically every time the system runs. If you need
certain resources globally throughout your application
you should consider auto-loading them for convenience.
To autoload resources, open the
application/config/autoload.php file and add the item
you want loaded to the autoload array.
Example :
$autoload['libraries']=array('form_validation','database',
'session');
12. Routing in CodeIgniter
Routing rules are defined in
your application/config/routes.php file. In it you’ll
see an array called $route that permits you to
specify your own routing criteria.
After all the basic changes we have to give a route
for our application which is set a default controller.
application/config/routes.php file
$route['default_controller'] = 'admin';
Remove the index_page from the
application/config/config.php file and leave it blank.
$config['index_page'] = '';
Lastly place the .htaccess file in the main project
folder, now all the routing process is done
13. Libraries
The essential part of a CodeIgniter framework is its
libraries. It provides a rich set of libraries, which
indirectly increase the speed of developing an
application. The system library is located at
system/libraries. All we need to do is to load the
library that we want to use.
Syntax for loading library into file :
$this->load->library(‘library_name');
Syntax for loading library with running system in
application/config/autoload.php :
$autoload[‘library'] = array(‘library_name');
14. List of Libraries
Benchmarking Class
Email Class
Encryption Library
Form Validation
FTP Class
Input Class
Loader Class
Pagination Class
Security Class
Session Library
URI Class
Zip Encoding Class
15. Helpers
Helpers, as the name suggests, help you with
tasks. Each helper file is simply a collection of
functions in a particular category.
They are simple, procedural functions. Each helper
function performs one specific task, with no
dependence on other functions.
CodeIgniter does not load Helper Files by default,
so the first step in using a Helper is to load it. Once
loaded, it becomes globally available in your
controller and views.
16. Syntax for loading helper into file :
$this->load->helper(‘helper_name');
Syntax for loading helper with running system in
application/config/autoload.php :
$autoload[‘helper'] = array('helper_name');
17. List of Helpers
Array Helper
Captcha Helper
Cookie Helper
Date Helper
Email Helper
File Helper
Form Helper
HTML Helper
Security Helper
Smiley Helper
Typography Helper
URL Helper
18. Models
Models are PHP classes that are designed to work
with information in your database.
CI_Model class must be extended Whenever u
want to create Your own Model.
Model name must be Started with Capital letter
Model name and file name must be Similar
Syntax for loading model into file :
$this->load->model('model_name');
Syntax for loading model with running system in
application/config/autoload.php :
$autoload['model'] = array('model_name');
19. Views
A view is simply a web page, or a page fragment,
like a header, footer, sidebar, etc.
Views are never called directly, they must be
loaded by a controller.
Syntax for loading view into file :
$this->load->view(‘view_name');
20. Controllers
Controllers are the heart of your application, as
they determine how HTTP requests should be
handled.
CI_Controller class must be extended Whenever u
want to create Your own Controller.
Controller name must be Started with Capital letter
Controller name and file name must be Similar
21. Basic application in
CodeIgniter
There is a Product application which is used to insert
and display the data of different product.
First we need to design database.
Next we are made a basic changes in application
which are needed to start development.
Next step is to design view files of the application.
After that we are going to create model and
controller for the application and code according to
the functionality of application.