CakePHP: An Introduction
Diana Jayne GonzalesWingcast Inc.
What is CakePHP?
Framework
Avoids re-inventing the wheel
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
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
Features
PHP4 and 5 compatible
Multiple DBs
ORM - Object Record Mapper
DB Objects
Validation
Caching
AJAX
Auth Module - Access Lists
Huge Code Base of Components and Plugins
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/)
Directory Structure● app/
○ config/○ controllers/○ models/○ plugins/○ tmp/○ vendors/○ views/○ webroot/
● cake/○ config/○ docs/○ libs/
● vendors/
Installing CakePHP
Get cake_1.1.17.5612.zip
Unzip to /var/www/
Rename folder to 'cake'
define('ROOT', BASE_DIR.'/path_to_cake_ins
tall');define ('APP_DIR', 'app');define ('WEBROOT_DIR',
'/public_html');
to app/webroot/index.php
Set up mod_rewrite
Setup database on config/database.php
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
Exercise: Scaffolding a Bookmarks Manager
automated way of generating a view based on the model
Exercise: Login
Exercise: AJAX Task List
Top Related