CakePHP: An Introduction

28
CakePHP: An Introduction Diana Jayne Gonzales Wingcast Inc.

Transcript of CakePHP: An Introduction

Page 1: CakePHP: An Introduction

CakePHP: An Introduction

Diana Jayne GonzalesWingcast Inc.

Page 2: CakePHP: An Introduction

What is CakePHP?

Page 3: CakePHP: An Introduction

Framework

Avoids re-inventing the wheel

Page 4: CakePHP: An Introduction
Page 5: CakePHP: An Introduction

Cake is for you if you want to...

do more things in less time

use a framework like RORstop creating the same codes

over and over again

templatingsearchable URLs

use MVC

use a framework that is suitable for all types of apps

Page 6: CakePHP: An Introduction

What Cake will do for you?

● eases creation of standard content management functionality (adding, editing and deleting)

● uses template-like Layouts and Views to separate logic from presentation

● validates form fields

● automatically escapes data saved to the database (to prevent SQL injection attacks)

● includes callbacks (eg. do an action before or after save)

● allows for both test and production databases

Page 7: CakePHP: An Introduction

Features

Page 8: CakePHP: An Introduction

PHP4 and 5 compatible

Page 9: CakePHP: An Introduction

Multiple DBs

Page 10: CakePHP: An Introduction

ORM - Object Record Mapper

DB Objects

Page 11: CakePHP: An Introduction

Validation

Page 12: CakePHP: An Introduction

Caching

Page 13: CakePHP: An Introduction

AJAX

Page 14: CakePHP: An Introduction

Auth Module - Access Lists

Page 15: CakePHP: An Introduction

Huge Code Base of Components and Plugins

Page 16: CakePHP: An Introduction

Resources● Taking A Look on 10 Different Frameworks (http://www.phpit.

net/article/ten-different-php-frameworks/)

● Cook Up Websites Fast with CakePHP (http://www.scribd.com/doc/5503/

CakePHP-tutorial-no-1-from-IBM)

● The CakePHP Framework: Your First Bite (http://www.sitepoint.com/article/

application-development-cakephp)

● CakePHP for Beginners: Tutorials (http://grahambird.co.uk/cake/tutorials/)

● CakePHP Manual(http://docs.huihoo.com/php/CakePHP-Manual/)

Page 17: CakePHP: An Introduction

Directory Structure● app/

○ config/○ controllers/○ models/○ plugins/○ tmp/○ vendors/○ views/○ webroot/

● cake/○ config/○ docs/○ libs/

● vendors/

Page 18: CakePHP: An Introduction

Installing CakePHP

Page 19: CakePHP: An Introduction

Get cake_1.1.17.5612.zip

Page 20: CakePHP: An Introduction

Unzip to /var/www/

Page 21: CakePHP: An Introduction

Rename folder to 'cake'

Page 22: CakePHP: An Introduction

define('ROOT', BASE_DIR.'/path_to_cake_ins

tall');define ('APP_DIR', 'app');define ('WEBROOT_DIR',

'/public_html');

to app/webroot/index.php

Page 23: CakePHP: An Introduction

Set up mod_rewrite

Page 24: CakePHP: An Introduction

Setup database on config/database.php

Page 25: CakePHP: An Introduction

Scaffolding

● analyzes your database tables

● creates standard lists with add, delete and edit buttons

● standard forms for editing and standard views for inspecting a single item in the database

Page 26: CakePHP: An Introduction

Exercise: Scaffolding a Bookmarks Manager

automated way of generating a view based on the model

Page 27: CakePHP: An Introduction

Exercise: Login

Page 28: CakePHP: An Introduction

Exercise: AJAX Task List