PHP + Framework + MVC CakePHP Lectures 1. What is Framework? CakePHP Lectures 2.

Slides:



Advertisements
Similar presentations
PHP + Framework + MVC. What is Framework? Common code - Generic functionality Extensible - Specific functionality Unlike library – Flow Dictated by.
Advertisements

CakePHP. A framework for developing applications in PHP Inspired by Ruby on Rails Follows MVC design pattern Convention over configuration –No wheel reinventing.
Struts Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
My Very First… Model View Controller Web Application with the Zend Framework New York City ZF Meetup.
July 2010 D2.1 Upgrading strategy Javier Soto Catalog Release 3. Communities.
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
NMD202 Web Scripting Week5. What we will cover today PHPmyAdmin Debugging – using print_r Modifying Data PHP (cont.) 4D Methodology File and IO operations.
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
Struts 2.0 an Overview ( )
Ruby on Rails. What is Ruby on Rails? Ruby on Rails is an open source full-stack web framework. It is an alternative to PHP/MySQL. It can render templates,
JQuery CS 268. What is jQuery? From their web site:
Dataface API Essentials Steve Hannah Web Lite Solutions Corp.
August Chapter 1 - Essential PHP spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science and Technology.
Danielle Baldwin, ITS Web Services CMS Administrator Application Overview and Joomla 1.5 RC 1 Highlights.
Electronically approve and create Suppliers in Oracle Financials using a combination of APEX and Oracle Workflow. NZOUG Conference 2010 Brad Sayer Team.
ZFApp Preview Walkthrough. What is ZFApp? ZFApp is an application framework built on top of Zend Framework Fully compatible with the latest ZF Versions.
ITM © Port, Kazman1 ITM 352 HTML Forms, Basic Form Processing.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Oracle Application Express 3.0 Joel R. Kallman Software Development Manager.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
© 2003 By Default! A Free sample background from Slide 1 Week 2  Free PHP Hosting Setup  PHP Backend  Backend Security 
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
PHP meets MySQL.
School of Computing and Information Systems CS 371 Web Application Programming CakePHP Server-side Framework.
Introduction to Model-Glue Rachel Lehman Perpetual Intermediate Designer-Developer Introduction to Model-Glue.
Ruby on Rails Your first app. Rails files app/ Contains the controllers, models, views and assets for your application. You’ll focus on this folder for.
CAKEPHP Blog tutorial. what you’ll need examples/blog/blog.html 2  A running web server  A database server.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Arnold Geraldo Designing and Making of The Online Auction Website Using CakePHP Framework.
Introduction to HTML. What is HTML?  Hyper Text Markup Language  Not a programming language but a markup language  Used for presentation and layout.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Overview: 1. Discussion of the basic architecture of a web application. 2. Discussion of the relevance of using MySQL and PHP in a web application.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
How does Drupal Work? Information Systems 337 Prof. Harry Plantinga.
Content Management System Copyright © 2005 Liferay, LLC All Rights Reserved. No material may be reproduced electronically or in print without written permission.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
ICM – API Server & Forms Gary Ratcliffe.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
Date : 3/04/2010 Web Technology Solutions Class: PHP Web Application Frameworks.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
PHP Form Processing * referenced from
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
START Application Spencer Johnson Jonathan Barella Cohner Marker.
Top 50 Interview Questions & Answers in CakePHP. 2 Question : 1 What is CakePHP?  CakePHP is a free, open-source, rapid development framework for PHP.
CakePHP.
Cake PHP – OOPS approach for PHP
PHP + Framework + MVC. What is Framework? Common code - Generic functionality Extensible - Specific functionality Unlike library – Flow Dictated.
Web Technology Solutions
Jim Fawcett CSE686 – Internet Programming Spring 2014
What is Laravel ? By Georgi Genov.
Jim Fawcett CSE686 – Internet Programming Spring 2012
MVC Architecture, Symfony Framework for PHP Web Apps
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Play Framework: Introduction
Play Framework: Introduction
ITM 352 Cookies.
Content Management System
Haritha Dasari Josue Balandrano Coronel -
PHP Training at GoLogica in Bangalore
Intro to PHP.
Presentation transcript:

PHP + Framework + MVC CakePHP Lectures 1

What is Framework? CakePHP Lectures 2

Common code - Generic functionality Extensible - Specific functionality Unlike library – Flow Dictated by Framework CakePHP Lectures 3

Reusable Design- May include: Support programs Code libraries Tools to develop and glue different components CakePHP Lectures 4

Why a Framework? CakePHP Lectures 5

I am lazy enough to write long codes, NAAAH... CakePHP Lectures 6

Technical Aspects: Proven Architecture Efficient (Code Re-usability) Scalable Extensible Modularity CakePHP Lectures 7

Developer Aspects: Easier maintenance Shorter development times. Flexible and less error-prone CakePHP Lectures 8

Focus => Specialized Functionality NOT Architecture Common Tools Work Flow CakePHP Lectures 9

How to choose Framework? CakePHP Lectures 10

CakePHP Lectures 11

Ofcourse, NOT CakePHP Lectures 12

Technical Aspects: Types of application, Types of framework Technical features of the framework Ease of development Ease of testing Tool support CakePHP Lectures 13

Viability Aspects: Frequent release Future enhancement Maturity – real life usage cases Proven market place? Production Environments? CakePHP Lectures 14

So, which one? CakePHP Lectures 15

The one which answers most of the above questions. CakePHP Lectures 16

PHP + Framework + MVC CakePHP CakePHP Lectures 17

Free Open Source Rapid Application Development Active Community Compatibility with PHP4 and PHP5 Project Age - 5yrs CakePHP Lectures 18

MVC Scaffolding Validation Data Sanitation ACL Components Helpers Security Session Caching CakePHP Lectures 19

Easy Installation – 2 Mins Easy Debugging Integrated Unit Testing CakePHP Lectures 20

Setting Up Cake: Setup Database Configuration CakePHP supports database drivers: mysql postgres sqlite pear-drivername (e.g. pear-mysql) adodb-drivername CakePHP Lectures 21

Cake Folder Structure CakePHP Lectures22 app/ config/ controllers/ models/ plugins/ tmp/ vendors/ views/ webroot/ cake/ config/ docs/ libs/ vendors/

CakePHP Lectures23 FolderWhat it Contains config Holds the (few) configuration files CakePHP uses. Database connection details, bootstrapping, core configuration files and more should be stored here. controllers Contains your application’s controllers and their components. localeStores string files for internationalization. models Contains your application’s models, behaviors, and datasources. pluginsContains plugin packages. tmp This is where CakePHP stores temporary data. The actual data it stores depends on how you have CakePHP configured, but this folder is usually used to store model descriptions, logs, and sometimes session information. Make sure that this folder exists and that it is writable, otherwise the performance of your application will be severely impacted. In debug mode, CakePHP will warn you if it is not the case. vendors Any third-party classes or libraries should be placed here. Doing so makes them easy to access using the App::import('vendor', 'name') function. Keen observers will note that this seems redundant, as there is also a vendors folder at the top level of our directory structure. We'll get into the differences between the two when we discuss managing multiple applications and more complex system setups. views Presentational files are placed here: elements, error pages, helpers, layouts, and view files. webroot In a production setup, this folder should serve as the document root for your application. Folders here also serve as holding places for CSS stylesheets, images, and JavaScript files.

The app folder will be where you work your magic: it’s where your application’s files will be placed. The cake folder is where we’ve worked our magic. Make a personal commitment not to edit files in this folder. We can’t help you if you’ve modified the core. Finally, the vendors folder is where you’ll place third-party PHP libraries you need to use with your CakePHP applications. CakePHP Lectures24

Models: Access point to a certain table in the database Contain data validation rules, association information, and methods specific to the table Extends AppModel CakePHP Lectures 25

Models: Table name in plural, like "users" and models in singular “user”. Mandatory Primary key named 'id'. Foreign keys naming: 'article_id'. (singular-table-name_id). 'created' / 'modified' column are automatically populated. CakePHP Lectures 26

Controllers: Manage the logic for a certain section or a single model. Include any number of actions Actions are functions used in your web application to display views Extends AppController CakePHP Lectures 27

class VideosController extends AppController { function view($id) { //action logic goes here.. } function rent($customer_id, $video_id) { //action logic goes here.. } function search($query) { //action logic goes here.. } example URLs: CakePHP Lectures 28

Controller action as a webservice Set WEBSERVICES in / app/config/core.php to 'on' Structure the logic in controller just as you normally would CakePHP Lectures 29

Views: a page template, usually named after an action. view for PostsController::add() would be found at /app/views/posts/add.ctp. simply PHP files, so you can use any PHP code inside them CakePHP Lectures 30

Views: data is passed as an array called $data data handed to the view using set() in the controller is also available in view. HTML helper is available in every view by default layout contains presentational code that wraps around view. Usually, common for one controller. CakePHP Lectures 31

Scaffolding: Way of getting the early parts of developing a web application started. Analyze database tables and creates standard lists, add, delete, edit. Add scaffolding by adding the $scaffold variable to controller. CakePHP Lectures 32

Components: Components are used to aid controllers in specific situations. A Reusable code which seamlessly sits inside Controller Sample Component Class class FooComponent extends Object { var $someVar = null; var $controller = true; function startup(&$controller) { // Perform controller initialization here. } function doFoo() { $this->someVar = 'foo'; } CakePHP Lectures 33

add the following code in your controller's definition: var $components = array('Foo'); Inside of that controller you could now use: $this->Foo->doFoo(); CakePHP Lectures 34

Helpers: Common functions to format views. Quick-and-easy creation of web forms image ( $path, $htmlAttributes, $return = false ); Renders an image tag. tableHeaders ( $names, $tr_options, $th_options ); create a formatted table header. CakePHP Lectures 35

Other Helpers: AJAX Javascript Number Text Time Cache (You can create your own helper.) CakePHP Lectures 36

Data Validation: Data in a Model conforms to the business rules. Example /app/models/user.php <?php class User extends AppModel { var $name = 'User'; var $validate = array( 'login' => '/[a-z0-9\_\-]{3,}$/i', 'password' => VALID_NOT_EMPTY, ' ' => VALID_ , 'born' => VALID_NUMBER ); } ?> CakePHP Lectures 37

Plugins: Distribute combination of controllers, models, and views as package. Example: Pizza Ordering Filesystem Layout /app /plugins /pizza /controllers <- plugin controllers go here /models <- plugin models go here /views <- plugin views go here /pizza_app_controller.php <- plugin's AppController,named after the plugin /pizza_app_model.php <- plugin's AppModel, named after the plugin CakePHP Lectures 38

ACL: Access Request Objects (AROs) and Access Control Objects (ACOs) $aro = new Aro(); // Create ARO $aro->create( 1, null, 'Bob Marley' ); // Create Groups $aro->create(0, null, 'Artists'); //Hook ARO with Group $aro->setParent('Artists', 'Bob Marley'); CakePHP Lectures 39

Creating ACOs and assigning permissions $aco = new Aco(); //Create some access control objects: $aco->create(1, null, 'Electric Guitar'); $this->Acl->allow('Abraham Lincoln', 'Electric Guitar','read'); CakePHP Lectures 40

// Check Access $access = $this->Acl->check($this->Session-> read('user_alias'), $aco, $action = "*"); //access denied if ($access === false) { echo "access denied"; exit; } CakePHP Lectures 41

Data Sanitation: Makes User Given Data Safe for use in SQL and HTML // First, include library and instantiate: uses('sanitize'); $mrClean = new Sanitize(); $badString = ";: echo $mrClean->paranoid($badString); // output: scripthtml echo $mrClean->paranoid($badString, array(' ', // output: scripthtml CakePHP Lectures 42

Sessions: Here are some of the functions you'll use most: check ($name); del ($name); delete ($name); Error (); flash ($key = 'flash'); read ($name); renew (); ; CakePHP Lectures 43

Security: RequirePost() class ThingsController extends AppController { var $components = array('Security'); function beforeFilter() { $this->Security->requirePost('delete'); } function delete($id) { // This will only happen if the action is called via an HTTP POST request $this->Thing->del($id); } CakePHP Lectures 44

5 Mins Blog Tutorial with Unit Testing CakePHP Lectures 45