PHP AIGERIM. Topics What is the framework? What is the framework? Why framework? Why framework? MVC Framework. MVC Framework.

Slides:



Advertisements
Similar presentations
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
Advertisements

Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
{ Model View Controller ASP.NET By Scott Crooks & Maggie Wettergreen.
Web Applications Development Using Coldbox Platform Eddie Johnston.
Fabian Vilers Hands on ASP.NET MVC.
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
Progress Report 11/1/01 Matt Bridges. Overview Data collection and analysis tool for web site traffic Lets website administrators know who is on their.
Multiple Tiers in Action
Software Architecture Patterns (2). what is architecture? (recap) o an overall blueprint/model describing the structures and properties of a "system"
Session-01. Layers Struts 2 Framework The struts 2 framework is used to develop MVC-based web application. Struts 1.0 was released in June The.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
DR. MOHAMMAD IQBAL THANKS TO ADITYA SENGUPTA Comparing Web Frameworks.
Web Application Architecture: multi-tier (2-tier, 3-tier) & mvc
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Overview of Framework by Ahamed Rifaudeen A. page - i Steps before entering into the Framework?  Basic knowledge of object-oriented programming (OOP)
UNIT-V The MVC architecture and Struts Framework.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
K.SWETHA. CSE-IV-A 08Q61A  INTRODUCTION  HISTORY  WORKING PROCESS  TECHNOLOGIES  ADVANTAGES AND DISADVANTAGES  CONCLUSION.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Codeigniter is an open source web application. It occupies a very small amount of space in the memory and is most useful for developers who aim to develop.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 21 - Web Servers (IIS, PWS and Apache) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3.
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
Comp4711 – Internet Development CodeIgniter Cookbook Comp4711 #2 – Sept 14, 2011.
Pemrograman Web MVC Programming and Design Pattern in PHP 5.
MVC Design Pattern Web Developer at Crimshield, Inc Application Developer at IBM Present - Delta Developer at Tides.
Web Application Design Patterns. Large Scale Architectures Early systems were monolithic applications –Large and hard to maintain Then came the client-server.
MVC Concepts Basics Model-View-Controller (MVC) Concepts for Web Developers SoftUni Team Technical Trainers Software University
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
Model View Controller. Tipe framework yang dominan: MVC Framework yang berdasarkan MVC membagi komponen dalam 3 bagian – Model, View, Controller Controller.
Apache JMeter By Lamiya Qasim. Apache JMeter Tool for load test functional behavior and measure performance. Questions: Does JMeter offers support for.
PHP on a Fast Track a quick introduction to PHP programming by Jarek Francik last time updated in 2012.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
Date : 3/04/2010 Web Technology Solutions Class: PHP Web Application Frameworks.
PHP Frameworks. Topics What is the framework? What is the framework? Why framework? Why framework? MVC Framework. MVC Framework. Ben-fits and Drawbacks.
 An essential supporting structure of any thing  A Software Framework  Has layered structure ▪ What kind of functions and how they interrelate  Has.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
ASP.NET MVC An Introduction. What is MVC The Model-View-Controller (MVC) is an architectural pattern separates an application into three main components:
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Basics Components of Web Design & Development Basics, Components, Design and Development.
Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Intro To MVC Architecture.
Introduction The concept of a web framework originates from the basic idea that every web application obtains its foundations from a similar set of guidelines.
Web Technology Solutions
Working with Server Side Scripting: PHP Framework (CodeIgniter)
Yii.
Introduction To Codeigniter
Web Development Web Servers.
Introduction to CodeIgniter (CI)
Server Concepts Dr. Charles W. Kann.
MVC and other n-tier Architectures
PHP Training at GoLogica in Bangalore
PHP / MySQL Introduction
Lecture 1: Multi-tier Architecture Overview
PHP Frameworks.
ASP.NET Module Subtitle.
WPS - your story so far Seems incredible complicated, already
Web Technologies Computing Science Thompson Rivers University
Web Application Development Using PHP
Software Engineering for Internet Applications
Presentation transcript:

PHP AIGERIM

Topics What is the framework? What is the framework? Why framework? Why framework? MVC Framework. MVC Framework. Benefits and Drawbacks of MVC. Benefits and Drawbacks of MVC. PHP Frameworks PHP Frameworks Example application using one of framework Example application using one of framework Screenshots Screenshots References References

What is a framework ? 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"; $db_name = “test"; $db_username = “root"; $db_password = “root"; $conn = mysql_connect($db_host,$db_username,$db_password) or die("Could not connect to Server".mysql_error()); mysql_select_db($db_name) or die("Could not connect to Database".mysql_error()); Edit : get code from databse and display at values of input boxes Display : <?php $query="iselect * from users "; $result = Mysql_query($query); While($get = mysql_fetch_assoc($result)) { ?> <?php } ?>

Same program using two tire architecture At the PHP file : <?php require 'libs/Smarty.class.php'; include "includes/functions.php"; $smarty = new Smarty; $smarty->assign("title",“Get data from Database"); $smarty->assign("keywords",get data, database"); $smarty->assign("description",“Get data from database process ") $query= “select * from users “; $result = Mysql_query(“$query”);” $getdata= mysql_fetch_array($result); $smarty->assign("data",$data); $smarty->display(‘userss.tpl'); ?> At a.tpl file {$title} Smarty ! {section name=rows loop=$data} {$data[rows]} {/section}

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. 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. Its easy to handle the complex problems easily. 1. Clean urls ( SEO friendly urls ) 1. Clean urls ( SEO friendly urls ) 2. We can standardization! 2. We can standardization! 3.Security 3.Security 4. Extensibility 4. Extensibility 5. Fast Loading 5. Fast Loading 6. Reusable of code 6. Reusable of code 7. increase flexibility 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

Webapps summary Accessed with a Web Browser (client) Accessed with a Web Browser (client) Over a network Over a network Code is mainly run on server Code is mainly run on server Exception: Javascript (also: Java, Flash,..) Exception: Javascript (also: Java, Flash,..) Code is loaded from server Code is loaded from server Data is mainly stored on server Data is mainly stored on server Webapps can be updated easily… Webapps can be updated easily…..without updating the clients!

General 3 tiered structure First tier: client side code (web-browser), e.g. (X)HTML, Javascript, Java, Flash First tier: client side code (web-browser), e.g. (X)HTML, Javascript, Java, Flash Second tier: server side code, e.g. C/C++, Perl, PHP, Java, Ruby, Python Second tier: server side code, e.g. C/C++, Perl, PHP, Java, Ruby, Python Third tier: server side database Third tier: server side database

Architectural Pattern from Smalltalk (1979) Architectural Pattern from Smalltalk (1979) Decouples data and presentation Decouples data and presentation Eases the development Eases the development 2. Model View Controller

First thought (ok, but not far enough): First thought (ok, but not far enough): Tier 1: View (Client) Tier 1: View (Client) Tier 2: Controller (Server) Tier 2: Controller (Server) Tier 3: Model (Database) Tier 3: Model (Database) Database ClientServer

Presentation: Presentation: View is the user interface (e.g. button) View is the user interface (e.g. button) Controller is the code (e.g. callback for button) Controller is the code (e.g. callback for button) Data: Data: Model is the database Model is the database Database Presentation Data

Example Control Flow in MVC User interacts with the VIEW UI User interacts with the VIEW UI CONTROLLER handles the user input (often a callback function attached to UI elements) CONTROLLER handles the user input (often a callback function attached to UI elements) CONTROLLER updates the MODEL CONTROLLER updates the MODEL VIEW uses MODEL to generate new UI VIEW uses MODEL to generate new UI UI waits for user interaction UI waits for user interaction

MVC – general example

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'] = ' $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']="Welcome to CodeIgniter Upload Images"; $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'] = ' '; $config['full_tag_close'] = ' '; $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']="List of images in the Website"; $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']="List of images in the Website"; $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

List Out Photos " /> pagination->create_links(); ?> Particular Image View Image " /> Views

Upload an Image Image Name: images/upload.png" value="Login" /> Upload a image

List of images : URL :

Particular Image URL :

Upload an image

Upload success page

References PHP framework comparison benchmarks PHP framework comparison benchmarks Why Should we use a PHP Framework? Why Should we use a PHP Framework? CakePHP official site CakePHP official site CodeIgniter Site CodeIgniter Site PHP frameworks lists PHP frameworks lists