SlideShare a Scribd company logo
PHP Frameworks
Topics What is the framework? Why framework? MVC Framework. Ben-fits and Drawbacks of MVC. PHP Frameworks Example application using one of framework Screenshots References
  What is a framework ?   For example, in order for a program to get data from a mysql database, it has to undergo a list of  actions:  1. Connect to the database server  2. Select a database  3. Query the database  4. Fetch the data  5. Use the Data  A framework may handle steps 1-4 for you, so that your responsibilities are reduced to:  1. Tell the framework to fetch the data  2. Use the data
Sample program in single tire architecture Connect to database : $db_host = “localhost&quot;; $db_name = “test&quot;; $db_username = “root&quot;; $db_password = “root&quot;; $conn = mysql_connect($db_host,$db_username,$db_password) or die(&quot;Could not connect to Server&quot; .mysql_error()); mysql_select_db($db_name) or die(&quot;Could not connect to Database&quot; .mysql_error()); <html> <head> </head> <body> Edit :   <form:> get code from databse and display at values of input boxes </form> Display : <table> <?php $query=&quot;iselect * from users &quot;; $result = Mysql_query($query); While($get = mysql_fetch_assoc($result)) { ?> <tr><td><?php echo $get[‘name’]?></td></tr> <?php }  ?> </table>
Same program using two tire architecture At the PHP file : <?php require 'libs/Smarty.class.php'; include &quot;includes/functions.php&quot;; $smarty = new Smarty; $smarty->assign(&quot;title&quot;,“Get data from Database&quot;); $smarty->assign(&quot;keywords&quot;,get data, database&quot;); $smarty->assign(&quot;description&quot;,“Get data from database process &quot;) $query= “select * from users “; $result = Mysql_query(“$query”);” $getdata= mysql_fetch_array($result); $smarty->assign(&quot;data&quot;,$data); $smarty->display(‘userss.tpl'); ?> <!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;> <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;> <head> <meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /> <title>{$title}</title> <meta name=&quot;keywords&quot; content=&quot;{$keywords}&quot; /> <meta name=&quot;description&quot; content=&quot;{$description}&quot; /> <<h1 class=&quot;title“>Smarty  !</h1> <ul class=&quot;list&quot; > {section name=rows loop=$data} {$data[rows]} {/section} </dody> </html> At a .tpl file
Why framework? Developing an application from scratch is easy than maintaining it . So after the development the  good thing is that its easy to maintain and add more features.  Its easy to handle the complex problems easily.   1. Clean urls ( SEO friendly urls ) 2. We can standardization!  3 .Security 4. Extensibility 5. Fast Loading 6. Reusable of code 7. increase flexibility
MVC Framework ->  MVC is a  method of separating the user interface of an application from its Domain Logic. -> MVC stands for Model, View, and Controller. It aims to separate your app in these 3 components: Model: ●  help you retrieve, insert, and update information in your database. View: ●  the information that is being presented to a user. Controller: ●  an intermediary between the Model, the View ●  any other resources needed to process the HTTP  request and generate a  web page
Substitutable user interface :  User interface components:  Multiple simultaneous views of the same model Synchronized views Easier user interface changes Easier testing Benefits  of using MVC Drawbacks  of using MVC   Increased complexity Close coupling of views and controllers to model Potential for excessive updates Close coupling between view and controller
MVC
Top 10 frameworks CodeIgniter Yii CakePHP Zend Symfony PHPDevShell Prado Akelos Zoop QPHP
Comparison of   frameworks
MVC : Indicates whether the framework comes with inbuilt support for a Model-View-Controller setup.  Multiple DB's : Indicates whether the framework supports multiple databases without having to change anything.  ORM : Indicates whether the framework supports an object-record mapper, usually an implementation of ActiveRecord.  DB Objects : Indicates whether the framework includes other database objects, like a TableGateWay.  Templates : Indicates whether the framework has an inbuilt template engine.  Caching : Indicates whether the framework includes a caching object or some way other way of caching.  Validation : Indicates whether the framework has an inbuilt validation or filtering component.  Ajax : Indicates whether the framework comes with inbuilt support for Ajax.  Auth Module : Indicates whether the framework has an inbuilt module for handling user authentication.  Modules : Indicates whether the framework has other modules, like an RSS feed parser, PDF module or anything else (useful). EDP : Event Driven Programming.New!
CodeIgniter Features
Configure the file: system/application/config/ $config['base_url'] = 'http://localhost/'; $config['index_page'] = ''; Default Settings : $config['charset'] = “UTF-8”; $config['cache_path'] = ''; $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-'; $config['log_date_format'] = 'Y-m-d H:i:s'; $config['global_xss_filtering'] = TRUE; To configure the databse: application\config\database.php  $db['default']['hostname'] = “”; // Host Name $db['default']['username'] = “”; // User Name $db['default']['password'] = “”; // Password $db['default']['database'] = “”; // Database Name $db['default']['dbdriver'] = “”; // Databse driver.
CodeIgniter URLs example.com/index.php/news/article/my_article news – Controller article – class function my_article - any additional segments If we add the below contents at .htaccess file DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]  Then URLs will change it into. example.com/news/article/my_article
<?php class Upload extends Controller { function Upload() { parent::Controller(); /* $this->load->helper('form');*/ } function index() { if ($this->session->userdata('logged_in') != TRUE)   {   redirect(base_url().'user/login');   } else {   //echo $this->session->userdata('name');     $data['login']=$this->session->userdata('name') ; } $this->load->database(); $data['title']=&quot;Welcome to CodeIgniter Upload Images&quot;; $this->load->view('header',$data); $this->load->view('upload_form'); $this->load->view('footer'); } function _createThumbnail($fileName) { $config['image_library'] = 'gd2'; $config['source_image'] = 'uploads/' . $fileName; $config['create_thumb'] = TRUE; $config['maintain_ratio'] = TRUE; $config['width'] = 75; $config['height'] = 75; $this->load->library('image_lib', $config); if(!$this->image_lib->resize()) echo $this->image_lib->display_errors(); } Controller
function list_images() { $this->load->database(); $this->load->library('pagination'); $config['total_rows'] = $this->db->count_all('code_image'); $config['per_page'] = '3'; $config['full_tag_open'] = '<p>'; $config['full_tag_close'] = '</p>';   $config['base_url'] = base_url().'upload/list_images/'; $this->pagination->initialize($config); //echo base_url(); $this->load->model('code_image'); $data['images'] = $this->code_image->get_images($config['per_page'],$this->uri->segment(3)); // This gives us anchor() - see the view at the end $data1['login']=$this->session->userdata('name') ; $data1['title']=&quot;List of images in the Website&quot;; $this->load->view('header',$data1); $this->load->helper('url'); $this->load->view('list_images', $data); $this->load->view('footer'); } function view_image($image_id) {   $this->load->database(); $this->load->model('code_image'); $data['image'] = $this->code_image->get_image($image_id); $data1['login']=$this->session->userdata('name') ; $data1['title']=&quot;List of images in the Website&quot;; $this->load->view('header',$data1); $this->load->view('view_image', $data); $this->load->view('footer'); } }
<?php class Code_image extends Model { function get_images($num, $offset) { $query = $this->db->get('code_image', $num, $offset); //$query = $this->db->get('code_image'); foreach ($query->result_array() as $row) { $result[] = $row; } return $result; } function get_image($image_id) { $query = $this->db->where('image_id', $image_id)->get('code_image'); $result = $query->row_array(); return $result; } } ?> Model
<table width=&quot;900&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; class=&quot;content&quot; > <tr><td><p>List Out Photos </p></td></tr> <tr> <td width=&quot;400&quot;> <table align=&quot;center&quot;> <?php foreach ($images as $image): ?> <tr><td colspan=&quot;2&quot; style=&quot; border-top:1px solid #669966;&quot;>&nbsp;</td></tr> <tr > <td width=&quot;200&quot;><img alt=&quot;Your Image&quot; src=&quot;<?= base_url() . 'uploads/' . $image['image_thumb'];?>&quot; /></td> <td width=&quot;200&quot;><?=anchor( base_url().'upload/view_image/'.$image['image_id'], 'View')?></td> </tr> <tr><td colspan=&quot;2&quot; style=&quot; border-bottom:1px solid #669966;&quot;>&nbsp;</td></tr> <?php endforeach; ?> <tr><td colspan=&quot;2&quot; style=&quot; border-bottom:1px solid #669966;&quot; align=&quot;right&quot;> <?php echo $this->pagination->create_links(); ?> &nbsp;</td></tr> </table> </td> </tr> </table> Particular Image <table width=&quot;900&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; class=&quot;content&quot; > <tr><td><p>View Image </p></td></tr> <tr> <td width=&quot;400&quot;> <table align=&quot;center&quot;> <tr><td colspan=&quot;2&quot; style=&quot; border-top:1px solid #669966;&quot;>&nbsp;</td></tr> <tr > <td width=&quot;400&quot;><img alt=&quot;Your Image&quot; src=&quot;<?= base_url() . 'uploads/' . $image['image_name'];?>&quot; /></td> </tr> <tr><td colspan=&quot;2&quot; style=&quot; border-bottom:1px solid #669966;&quot;>&nbsp;</td></tr> </table> </td> </tr> </table> Views
<table width=&quot;900&quot; height=&quot;200&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; class=&quot;content&quot; > <tr><td colspan=&quot;3&quot; align=&quot;left&quot;><h2>Upload an Image </h2></td></tr> <?php echo form_open_multipart(base_url().'upload/doUpload'); ?> <tr valign=&quot;top&quot;><td colspan=&quot;3&quot; align=&quot;center&quot;>  <table cellpadding=&quot;0&quot; cellspacing=&quot;2&quot; border=&quot;0&quot;> <tr> <td>&nbsp;</td> <td>Image Name: </td> <td><input type=&quot;file&quot; name=&quot;userfile&quot; /></td> <td>&nbsp;</td> <td><input type=&quot;image&quot; src=&quot;<?=base_url()?>images/upload.png&quot;  value=&quot;Login&quot; /></td> </tr> </table> </td> </tr> <?php echo form_close(); ?> </table> Upload a image
List of images :   URL : http://localhost/codeigniter/upload/list_images
Particular Image   URL : http://localhost/codeigniter/upload/view_image/1
Upload an image
Upload success   page
References PHP framework comparison benchmarks   http://avnetlabs.com/php/php-framework-comparison-benchmarks Why Should we use a PHP Framework? http://www.ashesh.com.np/why-should-we-use-a-php-framework/ CakePHP official site http://cakephp.org/ CodeIgniter Site http://codeigniter.com PHP frameworks lists h ttp://www.phpframeworks.com/ http://www.phpwact.org/pattern/model_view_controller
For any quires  - kumaranil21@gmail.com Thank you

More Related Content

ODP
Web Scraping with PHP
ODP
Zend Framework 1.9 Setup & Using Zend_Tool
PPTX
Migrate yourself. code -> module -> mind
PDF
Doctrine 2
PDF
REST API with CakePHP
PPTX
The Django Web Application Framework 2
PDF
Drupal 8 Services
KEY
PHP security audits
Web Scraping with PHP
Zend Framework 1.9 Setup & Using Zend_Tool
Migrate yourself. code -> module -> mind
Doctrine 2
REST API with CakePHP
The Django Web Application Framework 2
Drupal 8 Services
PHP security audits

What's hot (18)

PDF
E2 appspresso hands on lab
PDF
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
PDF
Drupal 8 Services And Dependency Injection
PPTX
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
PPTX
Web development with django - Basics Presentation
PPTX
Let's write secure Drupal code! DUG Belgium - 08/08/2019
PPTX
Let's write secure drupal code! - Drupal Camp Pannonia 2019
PPTX
Let's write secure Drupal code! - Drupal Camp Poland 2019
PDF
Php Security
PDF
WebGUI Developers Workshop
PPTX
User registration and login using stored procedure in php
TXT
Jsp Notes
PDF
TurboGears2 Pluggable Applications
PDF
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
PDF
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
PPTX
Rest with Java EE 6 , Security , Backbone.js
PDF
And now you have two problems. Ruby regular expressions for fun and profit by...
PPTX
Drupal 8 Deep Dive: What It Means for Developers Now that REST Is in Core
E2 appspresso hands on lab
Hyperproductive JSF 2.0 @ JavaOne Brazil 2010
Drupal 8 Services And Dependency Injection
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Web development with django - Basics Presentation
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure Drupal code! - Drupal Camp Poland 2019
Php Security
WebGUI Developers Workshop
User registration and login using stored procedure in php
Jsp Notes
TurboGears2 Pluggable Applications
Spark IT 2011 - Simplified Web Development using Java Server Faces 2.0
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Rest with Java EE 6 , Security , Backbone.js
And now you have two problems. Ruby regular expressions for fun and profit by...
Drupal 8 Deep Dive: What It Means for Developers Now that REST Is in Core
Ad

Viewers also liked (20)

PPT
Designing of databases
PPTX
Code snippets of PHP and Javascript by Anil Kumar Panigrahi
PDF
Yii, frameworks and where PHP is heading to
PPTX
Yii2 by Peter Jack Kambey
PPTX
Web 2 0
PPT
Казнадзей назар. SendFlowers.ua. 2014
PDF
IT People PechaKucha - Ульяна Ходоровская - Востребованность языков программи...
PPTX
створення Web сторінок
PPT
Cannes 2008 Presentation
PDF
Шлях від студента до веб-розробника
PPT
PHP up file
PPTX
PPT
PHP Frameworks and CodeIgniter
PDF
Yii2 restful 基礎教學
PPTX
Cтеки іт технологій
PDF
How the Web Works
PPTX
About Best friends - HTML, CSS and JS
Designing of databases
Code snippets of PHP and Javascript by Anil Kumar Panigrahi
Yii, frameworks and where PHP is heading to
Yii2 by Peter Jack Kambey
Web 2 0
Казнадзей назар. SendFlowers.ua. 2014
IT People PechaKucha - Ульяна Ходоровская - Востребованность языков программи...
створення Web сторінок
Cannes 2008 Presentation
Шлях від студента до веб-розробника
PHP up file
PHP Frameworks and CodeIgniter
Yii2 restful 基礎教學
Cтеки іт технологій
How the Web Works
About Best friends - HTML, CSS and JS
Ad

Similar to Php frameworks (20)

PPT
Create a web-app with Cgi Appplication
ODP
Exploring Symfony's Code
PDF
Intro To Mvc Development In Php
PPTX
I Love codeigniter, You?
PPT
Framework
PPT
P H P Part I I, By Kian
PPT
Testing persistence in PHP with DbUnit
ODP
Practical catalyst
PPT
What's New in ZF 1.10
ODP
CodeIgniter PHP MVC Framework
PPT
Slick Data Sharding: Slides from DrupalCon London
PPT
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PDF
How to Create Login and Registration API in PHP.pdf
PPTX
5 Reasons To Love CodeIgniter
PPTX
working with PHP & DB's
PPT
Php Data Objects
PPTX
Nodejs.meetup
PPT
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
PDF
AEM Sightly Deep Dive
PPTX
The Django Web Application Framework 2
Create a web-app with Cgi Appplication
Exploring Symfony's Code
Intro To Mvc Development In Php
I Love codeigniter, You?
Framework
P H P Part I I, By Kian
Testing persistence in PHP with DbUnit
Practical catalyst
What's New in ZF 1.10
CodeIgniter PHP MVC Framework
Slick Data Sharding: Slides from DrupalCon London
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
How to Create Login and Registration API in PHP.pdf
5 Reasons To Love CodeIgniter
working with PHP & DB's
Php Data Objects
Nodejs.meetup
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
AEM Sightly Deep Dive
The Django Web Application Framework 2

Recently uploaded (20)

PDF
From loneliness to social connection charting
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
From loneliness to social connection charting
human mycosis Human fungal infections are called human mycosis..pptx
Cell Structure & Organelles in detailed.
Introduction and Scope of Bichemistry.pptx
Open folder Downloads.pdf yes yes ges yes
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
NOI Hackathon - Summer Edition - GreenThumber.pptx
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
UPPER GASTRO INTESTINAL DISORDER.docx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
The Final Stretch: How to Release a Game and Not Die in the Process.
Open Quiz Monsoon Mind Game Prelims.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Revamp in MTO Odoo 18 Inventory - Odoo Slides

Php frameworks

  • 2. Topics What is the framework? Why framework? MVC Framework. Ben-fits and Drawbacks of MVC. PHP Frameworks Example application using one of framework Screenshots References
  • 3. What is a framework ? For example, in order for a program to get data from a mysql database, it has to undergo a list of actions: 1. Connect to the database server 2. Select a database 3. Query the database 4. Fetch the data 5. Use the Data A framework may handle steps 1-4 for you, so that your responsibilities are reduced to: 1. Tell the framework to fetch the data 2. Use the data
  • 4. Sample program in single tire architecture Connect to database : $db_host = “localhost&quot;; $db_name = “test&quot;; $db_username = “root&quot;; $db_password = “root&quot;; $conn = mysql_connect($db_host,$db_username,$db_password) or die(&quot;Could not connect to Server&quot; .mysql_error()); mysql_select_db($db_name) or die(&quot;Could not connect to Database&quot; .mysql_error()); <html> <head> </head> <body> Edit : <form:> get code from databse and display at values of input boxes </form> Display : <table> <?php $query=&quot;iselect * from users &quot;; $result = Mysql_query($query); While($get = mysql_fetch_assoc($result)) { ?> <tr><td><?php echo $get[‘name’]?></td></tr> <?php } ?> </table>
  • 5. Same program using two tire architecture At the PHP file : <?php require 'libs/Smarty.class.php'; include &quot;includes/functions.php&quot;; $smarty = new Smarty; $smarty->assign(&quot;title&quot;,“Get data from Database&quot;); $smarty->assign(&quot;keywords&quot;,get data, database&quot;); $smarty->assign(&quot;description&quot;,“Get data from database process &quot;) $query= “select * from users “; $result = Mysql_query(“$query”);” $getdata= mysql_fetch_array($result); $smarty->assign(&quot;data&quot;,$data); $smarty->display(‘userss.tpl'); ?> <!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;> <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;> <head> <meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /> <title>{$title}</title> <meta name=&quot;keywords&quot; content=&quot;{$keywords}&quot; /> <meta name=&quot;description&quot; content=&quot;{$description}&quot; /> <<h1 class=&quot;title“>Smarty !</h1> <ul class=&quot;list&quot; > {section name=rows loop=$data} {$data[rows]} {/section} </dody> </html> At a .tpl file
  • 6. Why framework? Developing an application from scratch is easy than maintaining it . So after the development the good thing is that its easy to maintain and add more features. Its easy to handle the complex problems easily. 1. Clean urls ( SEO friendly urls ) 2. We can standardization! 3 .Security 4. Extensibility 5. Fast Loading 6. Reusable of code 7. increase flexibility
  • 7. MVC Framework -> MVC is a method of separating the user interface of an application from its Domain Logic. -> MVC stands for Model, View, and Controller. It aims to separate your app in these 3 components: Model: ● help you retrieve, insert, and update information in your database. View: ● the information that is being presented to a user. Controller: ● an intermediary between the Model, the View ● any other resources needed to process the HTTP request and generate a web page
  • 8. Substitutable user interface : User interface components: Multiple simultaneous views of the same model Synchronized views Easier user interface changes Easier testing Benefits of using MVC Drawbacks of using MVC Increased complexity Close coupling of views and controllers to model Potential for excessive updates Close coupling between view and controller
  • 9. MVC
  • 10. Top 10 frameworks CodeIgniter Yii CakePHP Zend Symfony PHPDevShell Prado Akelos Zoop QPHP
  • 11. Comparison of frameworks
  • 12. MVC : Indicates whether the framework comes with inbuilt support for a Model-View-Controller setup. Multiple DB's : Indicates whether the framework supports multiple databases without having to change anything. ORM : Indicates whether the framework supports an object-record mapper, usually an implementation of ActiveRecord. DB Objects : Indicates whether the framework includes other database objects, like a TableGateWay. Templates : Indicates whether the framework has an inbuilt template engine. Caching : Indicates whether the framework includes a caching object or some way other way of caching. Validation : Indicates whether the framework has an inbuilt validation or filtering component. Ajax : Indicates whether the framework comes with inbuilt support for Ajax. Auth Module : Indicates whether the framework has an inbuilt module for handling user authentication. Modules : Indicates whether the framework has other modules, like an RSS feed parser, PDF module or anything else (useful). EDP : Event Driven Programming.New!
  • 14. Configure the file: system/application/config/ $config['base_url'] = 'http://localhost/'; $config['index_page'] = ''; Default Settings : $config['charset'] = “UTF-8”; $config['cache_path'] = ''; $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-'; $config['log_date_format'] = 'Y-m-d H:i:s'; $config['global_xss_filtering'] = TRUE; To configure the databse: application\config\database.php $db['default']['hostname'] = “”; // Host Name $db['default']['username'] = “”; // User Name $db['default']['password'] = “”; // Password $db['default']['database'] = “”; // Database Name $db['default']['dbdriver'] = “”; // Databse driver.
  • 15. CodeIgniter URLs example.com/index.php/news/article/my_article news – Controller article – class function my_article - any additional segments If we add the below contents at .htaccess file DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] Then URLs will change it into. example.com/news/article/my_article
  • 16. <?php class Upload extends Controller { function Upload() { parent::Controller(); /* $this->load->helper('form');*/ } function index() { if ($this->session->userdata('logged_in') != TRUE) { redirect(base_url().'user/login'); } else { //echo $this->session->userdata('name'); $data['login']=$this->session->userdata('name') ; } $this->load->database(); $data['title']=&quot;Welcome to CodeIgniter Upload Images&quot;; $this->load->view('header',$data); $this->load->view('upload_form'); $this->load->view('footer'); } function _createThumbnail($fileName) { $config['image_library'] = 'gd2'; $config['source_image'] = 'uploads/' . $fileName; $config['create_thumb'] = TRUE; $config['maintain_ratio'] = TRUE; $config['width'] = 75; $config['height'] = 75; $this->load->library('image_lib', $config); if(!$this->image_lib->resize()) echo $this->image_lib->display_errors(); } Controller
  • 17. function list_images() { $this->load->database(); $this->load->library('pagination'); $config['total_rows'] = $this->db->count_all('code_image'); $config['per_page'] = '3'; $config['full_tag_open'] = '<p>'; $config['full_tag_close'] = '</p>'; $config['base_url'] = base_url().'upload/list_images/'; $this->pagination->initialize($config); //echo base_url(); $this->load->model('code_image'); $data['images'] = $this->code_image->get_images($config['per_page'],$this->uri->segment(3)); // This gives us anchor() - see the view at the end $data1['login']=$this->session->userdata('name') ; $data1['title']=&quot;List of images in the Website&quot;; $this->load->view('header',$data1); $this->load->helper('url'); $this->load->view('list_images', $data); $this->load->view('footer'); } function view_image($image_id) { $this->load->database(); $this->load->model('code_image'); $data['image'] = $this->code_image->get_image($image_id); $data1['login']=$this->session->userdata('name') ; $data1['title']=&quot;List of images in the Website&quot;; $this->load->view('header',$data1); $this->load->view('view_image', $data); $this->load->view('footer'); } }
  • 18. <?php class Code_image extends Model { function get_images($num, $offset) { $query = $this->db->get('code_image', $num, $offset); //$query = $this->db->get('code_image'); foreach ($query->result_array() as $row) { $result[] = $row; } return $result; } function get_image($image_id) { $query = $this->db->where('image_id', $image_id)->get('code_image'); $result = $query->row_array(); return $result; } } ?> Model
  • 19. <table width=&quot;900&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; class=&quot;content&quot; > <tr><td><p>List Out Photos </p></td></tr> <tr> <td width=&quot;400&quot;> <table align=&quot;center&quot;> <?php foreach ($images as $image): ?> <tr><td colspan=&quot;2&quot; style=&quot; border-top:1px solid #669966;&quot;>&nbsp;</td></tr> <tr > <td width=&quot;200&quot;><img alt=&quot;Your Image&quot; src=&quot;<?= base_url() . 'uploads/' . $image['image_thumb'];?>&quot; /></td> <td width=&quot;200&quot;><?=anchor( base_url().'upload/view_image/'.$image['image_id'], 'View')?></td> </tr> <tr><td colspan=&quot;2&quot; style=&quot; border-bottom:1px solid #669966;&quot;>&nbsp;</td></tr> <?php endforeach; ?> <tr><td colspan=&quot;2&quot; style=&quot; border-bottom:1px solid #669966;&quot; align=&quot;right&quot;> <?php echo $this->pagination->create_links(); ?> &nbsp;</td></tr> </table> </td> </tr> </table> Particular Image <table width=&quot;900&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; class=&quot;content&quot; > <tr><td><p>View Image </p></td></tr> <tr> <td width=&quot;400&quot;> <table align=&quot;center&quot;> <tr><td colspan=&quot;2&quot; style=&quot; border-top:1px solid #669966;&quot;>&nbsp;</td></tr> <tr > <td width=&quot;400&quot;><img alt=&quot;Your Image&quot; src=&quot;<?= base_url() . 'uploads/' . $image['image_name'];?>&quot; /></td> </tr> <tr><td colspan=&quot;2&quot; style=&quot; border-bottom:1px solid #669966;&quot;>&nbsp;</td></tr> </table> </td> </tr> </table> Views
  • 20. <table width=&quot;900&quot; height=&quot;200&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; class=&quot;content&quot; > <tr><td colspan=&quot;3&quot; align=&quot;left&quot;><h2>Upload an Image </h2></td></tr> <?php echo form_open_multipart(base_url().'upload/doUpload'); ?> <tr valign=&quot;top&quot;><td colspan=&quot;3&quot; align=&quot;center&quot;> <table cellpadding=&quot;0&quot; cellspacing=&quot;2&quot; border=&quot;0&quot;> <tr> <td>&nbsp;</td> <td>Image Name: </td> <td><input type=&quot;file&quot; name=&quot;userfile&quot; /></td> <td>&nbsp;</td> <td><input type=&quot;image&quot; src=&quot;<?=base_url()?>images/upload.png&quot; value=&quot;Login&quot; /></td> </tr> </table> </td> </tr> <?php echo form_close(); ?> </table> Upload a image
  • 21. List of images : URL : http://localhost/codeigniter/upload/list_images
  • 22. Particular Image URL : http://localhost/codeigniter/upload/view_image/1
  • 25. References PHP framework comparison benchmarks http://avnetlabs.com/php/php-framework-comparison-benchmarks Why Should we use a PHP Framework? http://www.ashesh.com.np/why-should-we-use-a-php-framework/ CakePHP official site http://cakephp.org/ CodeIgniter Site http://codeigniter.com PHP frameworks lists h ttp://www.phpframeworks.com/ http://www.phpwact.org/pattern/model_view_controller