CakePHP. A framework for developing applications in PHP Inspired by Ruby on Rails Follows MVC design pattern Convention over configuration –No wheel reinventing.

Slides:



Advertisements
Similar presentations
WordPress Installation for Beginners Sheila Bergman
Advertisements

Applied Ruby on Rails & AJAX An insight into the technology and principles behind a social networking community.
PHP + Framework + MVC. What is Framework? Common code - Generic functionality Extensible - Specific functionality Unlike library – Flow Dictated by.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 The Web Wizards Guide to PHP by David Lash.
Other Web Application Development Technologies. PHP.
Ian J Robotham Software Development Lead Medi-CAL Unit, University of Aberdeen.
My Very First… Model View Controller Web Application with the Zend Framework New York City ZF Meetup.
Database Chapters.
건전지로 달리는 쟝고 세미나. 정재성 Django Web Framework CGI.
Ibiza, June 6 th 2011 Advanced Database Install Scripts.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013.
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Housing and Dining Online by Andrew Gorges. Outline  Overview of PHP  Overview of MySQL  Using PHP  Using MySQL  PHP and MySQL together  Production.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
CakePHP A PHP Framework. CakePHP A framework for developing applications in PHP Inspired by Ruby on Rails Follows MVC design pattern Convention over configuration.
Chapter 15 © 2010 by Addison Wesley Longman, Inc Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in Use spread rapidly.
Amit Kumar Singh ITBrainShapers. MVC Model Data layer View Presentation layer Controller Logic layer.
Ruby on Rails. What's Ruby  A programming language  Developed by Yukihiro Matsumoto (aka Matz) in the 1990s  A programming language  Developed by.
A complete web app using flex. You can use the flex builder to generate the php (server side) code for a flex-php application. As before, Php connects.
27-Jun-15 Rails. What is Rails? Rails is a framework for building web applications This involves: Getting information from the user (client), using HTML.
Ruby on Rails: An Introduction JA-SIG Summer Conference 2007 Michael Irion The University of Tulsa.
A little engineering on Rails Robert W. Hasker. Goals Intro to the Rails framework ▫Basic concepts: MVC, Active Record ▫A bit of Ruby Using Rails to build.
RUBY ON RAILS It’s so rad. What we’ll cover  What is Ruby?  What is RoR?  Why RoR?  Developing with RoR  Deployment  Demo  Questions.
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,
MySql In Action Step by step method to create your own database.
U NIT 4 F ILE U PLOAD. I. C REATE AN U PLOAD -F ILE F ORM - With PHP, it is possible to upload files to the server.To allow users to upload files from.
Rails and Grails. To get started Make sure you have java installed You can get the sdk and jre at:
Movie Manager by Patrick Wesley and Chris Grey Internet Database Project for CS 8630 – Summer 2004 Dr. Guimaraes.
Stored Procedures, Triggers, Program Access Dr Lisa Ball 2008.
School of Computing and Information Systems CS 371 Web Application Programming CakePHP Server-side Framework.
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.
PHP + Framework + MVC CakePHP Lectures 1. What is Framework? CakePHP Lectures 2.
Pemrograman Web MVC Programming and Design Pattern in PHP 5.
Introduction to MySQL Lab no. 10 Advance Database Management System.
CAKEPHP Blog tutorial. what you’ll need examples/blog/blog.html 2  A running web server  A database server.
PHP MySQL Image Gallery. The admin section contain the following : Add New Album Album List Edit & Delete Album Add Image Image List Edit & Delete Image.
MVC Design Pattern Web Developer at Crimshield, Inc Application Developer at IBM Present - Delta Developer at Tides.
MVC Concepts Basics Model-View-Controller (MVC) Concepts for Web Developers SoftUni Team Technical Trainers Software University
Introduction to MVC Controllers NTPCUG Tom Perkins, Ph.D.
Ruby on Rails By S. Christopher Hellriegel. Overview 1. What is Ruby on Rails? 2. What is MVC? 3. Simple example 4. Wow, that was cool!
Summary 1 Gordon Tian CS520/CS596_026. HTTP Browser – Chrome | FireFox XML/HTML/CSS3/JavaScript/REST Web Server – Nginx PHP/Python/Perl/Java/Ruby/Node.js.
MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which.
DATABASE DEVELOPMENT WITH VSTS DATABASE EDITION By Chris Dahlberg ©2009 Aspect Software, Inc. All rights reserved. 1.
 Empowers to your customer  Product Rating and its Management in Ecommerce Framework  Product Reviews and Management: Collecting customer opinion about.
Date : 3/04/2010 Web Technology Solutions Class: PHP Web Application Frameworks.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Introduction to information systems RUBY ON RAILS dr inż. Tomasz Pieciukiewicz.
DATABASE DEVELOPMENT WITH VISUAL STUDIO 2010 Chris Dahlberg 1.
App Package Folder App data Folders Local Roaming Temp Removable Storage (SD Card) Cloud Credential Locker B/ground Transfer Publishers Shared Folder.
Web Application Design. Data –What data is available? –How do we store it or how is it stored in the DB? Schema Data types Etc. –Where is the data?
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
Lab 3.21 MySQL Database Lab Developing the Tools May 5 th, 2004 Montréal, Québec Dominik Gehl Hôpital Ste-Justine, Montréal.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
Reactor An ORM framework for ColdFusion Presentation By: Doug Hughes
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.
Web Technology Solutions
Play Framework: Introduction
Introduction to CodeIgniter (CI)
(Arnulf's Tcl Web Framework)
PHP Training at GoLogica in Bangalore
Introduction to MVC PHP Web Development Ivan Yonkov Training Manager
Social Media And Global Computing Managing MVC with Custom Models
Project Phase II Instructions &Sample Code
MVC Controllers.
SQL AUTO INCREMENT Field
Presentation transcript:

CakePHP

A framework for developing applications in PHP Inspired by Ruby on Rails Follows MVC design pattern Convention over configuration –No wheel reinventing required!

MVC Model –Data layer View –Presentation layer Controller –Logic layer

CakePHP Framework app/ config/ controllers/ models/ plugins/ tmp/ vendors/ views/ webroot/ cake/ config/ docs/ libs/ vendors/

Naming conventions Conventions Table names: notes, my_notes Model: mynote.php->MyNote Controller: my_notes_controller.php-> MyNotesController Views named after actions, organised in folders according to the related controller: –views/my_notes/index.thtml –views/my_notes/add.thtml

Paths + parameters Cake uses url to pass parameters Apache mod_rewrite converts url into scriptname and parameters /controllername/action/param1/param2/… Uses paths to figure out views Views stored in controllername folder

OOP in PHP Limited support in PHP <5 Much better support in PHP >=5 Simpler than Java OOP class SomeClass { function func() { …. } SomeClass s = new someClass(); s->func();

Hello world… again Remember application is separated into model / view / controller Model: <?php /* /app/model/hello.php */ class Hello extends AppModel { var $name = 'Hello'; var $useTable = false; } ?>

Hello world… again View: <!-- /* /app/views/index.thtml */ -->

Controller: <?php /* app/controller/hello_controller.php */ class HelloController extends AppController { var $name = "Hello"; var $uses = 'Hello'; function index() { $data = 'Hello world!'; $this->set('data', $data); } ?>

Simple DB table app An online contact list We want to add, edit, view and delete names and phone numbers Uses a single table

Model Add table to DB: CREATE TABLE cake_contacts ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), number VARCHAR(50), created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL );

Model Add a script called contact.php to models/ <?php class Contact extends AppModel { var $name = Contact'; } ?>

View views/contacts/index.thtml Contact list link('Add Contact', 'contacts/add') ?> Id Name Number

View views/contacts/index.thtml cntd… <?php echo $html->link($contact['Contact'][name'], "contacts/view/{$contact['Contact']['id']}")?> [ link('Edit', "contacts/edit/{$contact['Contact']['id']}")?>, link('Delete', "contacts/delete/{$contact['Contact']['id']}", null, 'Sure?')?>]

View views/contacts/view.thtml Created:

View views/contacts/add.thtml Add Contact url("contacts/add"); ?>" method="post"> Name: input('Contact/name', array('size' => '40')) ?> Number: input('Contact/number', array('size' => '40')) ?> submit('Save') ?>

View views/contacts/edit.thtml Edit Contact url('/contacts/edit')?>" method="post"> hidden('Contact/id'); ?> Name: input('Contact/name', array('size' => '40')) ?> Number: input('Contact/number', array('size' => '40')) ?> submit('Save') ?>

Controller /app/controllers/notes_controller.php: <?php class ContactsController extends AppController { var $name = 'Contacts'; function index() { $this->set('contacts', $this->Contact- >findAll()); } function view($id) { $this->Contact->id = $id; $this->set('data', $this->Contact->read()); }

Controller /app/controllers/notes_controller.php: function add() { if (!empty($this->data['Contact'])) { if($this->Contact->save($this->data['Contact'])) { $this->flash('Your contact has been added.', /contacts/'); } function delete($id) { if ($this->Contact->del($id)) { $this->flash('The contact with id: '.$id.' has been deleted.', /contacts/'); }

Controller /app/controllers/notes_controller.php: function edit($id = null) { if (empty($this->data['Contact'])) { $this->Contact->id = $id; $this->data = $this->Contact->read(); } else { if($this->Contact->save($this->data['Contact'])) { $this->flash('Your contact has been updated.',/contacts/'); } ?>

Resulting application …../cake/contacts/view/4…../cake/contacts/edit/1…../cake/contacts/add

Other benefits Bake script – command line script generator Uses LAMP common web platform –(Linux, Apache, MySQL and PHP) Helpers for HTML, Forms, Pagination, AJAX, Javascript, XML, RSS Scaffolding (no need for views) –Create controller with var $scaffold;

Disadvantages Mainly due to the limitations of PHP –Clumsy OOP –Access data through arrays not classes (which RoR does) – more code in view Create tables in separate SQL Not well documented yet