Learn How To Develop With CakePHP

29
Learn how to develop with CakePHP Boston PHP : Michael Bourque Feb 17 th , 2010 Part I

description

If you don't already use a PHP framework then this is for you. CakePHP is one of the more popular frameworks and is similar to RubyOnRails.I will start you off at the very beginning as though you know nothing about CakePHP.

Transcript of Learn How To Develop With CakePHP

Page 1: Learn How To Develop With CakePHP

Learn how to develop with

CakePHP

Boston PHP : Michael Bourque

Feb 17th, 2010

Part I

Page 2: Learn How To Develop With CakePHP

Welcome to Boston PHP

Started in 2002 Open styled meetings 66 Meetings so far 600 Members strong Location, Location,

Location Boston, Cambridge,

Norwell, Salem, Somerville, Quincy

MIT, Microsoft, BU meetup.com/bostonphp

Page 3: Learn How To Develop With CakePHP

Boston PHP Past Meetings

Learn how to create a FaceBook app

SHOW n' TELL night The ultimate PHP "date

night"... Debugging and a movie

Framework Bake off... Get Smart - Use Smarty! Lessons from

my.barackobama.com jQuery and the Last Mile PHP IDE Bake-Off Mediawiki in production

Flex & the Zend Framework An introduction to jQuery The mystery of CSS and

Design Choosing an OSS license to

match your business model Developing, pricing &

delivering OSS applications How to get your OSS

venture off the ground. What is Agile Scrum? Building the PHP-stack for

the enterprise Object-Relational Mapping

(ORM) in action

Page 4: Learn How To Develop With CakePHP

March 10: Cake PHP part II

Join us for part II in our series on CakePHP framework. Join Chris and Jesse Kochis as they give you a more in-depth advanced view of CakePHP.

Page 5: Learn How To Develop With CakePHP

April 7: Enhance your apps jQuery

What is jQuery How to install Syntax Review of the documentation Practical uses of jQuery in your app

Light-box dialogs Form validation Effects such as Animation, Fading, Easing, Etc Ajax Page blocking Progressive enhancements

How to use jQuery plugins jQuery UI More...

Page 6: Learn How To Develop With CakePHP

Design an app without writing a single line of code

How to think about your app and start to experiment with your ideas

Prototyping tools Prototyping single pages and user

interactions Creating a linkable prototype that

looks almost like a working app Exporting your prototype to the

web for remote testing and design feedback

Paper prototyping and usability testing

Designing a great user experience with interaction design

Page 7: Learn How To Develop With CakePHP

Startup/Hack Month

Come to the podium and post an idea for an app that does not yet exists or could be improved. You should be willing to share this idea and not an idea that you’re not willing to

share with others Ask for volunteers to help you take your idea and conceptualize it into a

low fidelity prototype Work as a team onsite to produce the low fidelity prototype Present your prototype to the audience Plan with your team how best to build the app.

What technology you will use What roles each other can play How your team will work together

Come back to BostonPHP (one month later) and present your progress and demo what you have so far Discuss what technology your using Discuss how you were organized What worked well, what didn’t What you would like to do next

Page 8: Learn How To Develop With CakePHP

PHP Security

Cross-Site Request Forgeries Cross-Site Scripting Session Fixation Cross-Site Session Transfer Pseudo-Random Number Generator Attacks SQL Injection Email Injection Path Disclosure Path Traversal Request Value Fixation Invalid Character Encoding File Uploads Password Hashing Magic Quotes and Register Globals- Cryptography

Mistakes

Page 9: Learn How To Develop With CakePHP

Tell us what you want!

Learning series Open source Web development Web design Frameworks Application design … Vote now!

meetup.com/bostonphp/ideas

Page 10: Learn How To Develop With CakePHP

Boston PHP : Volunteers needed

Webmaster Logistics Video cameraman Topic Presenters More…

Page 11: Learn How To Develop With CakePHP

Boston PHP : Free

Page 12: Learn How To Develop With CakePHP

Learn how to develop with

CakePHP

Boston PHP : Michael Bourque

Part I

Page 13: Learn How To Develop With CakePHP

Why a framework?

<?php echo “why?”;

?>

Page 14: Learn How To Develop With CakePHP

What do most WebApps do? Display HTML

Static pages Dynamic pages Forms

Handle form data CRUD (Create, Read, Update, Delete) Security Authentication Authorization Caching Etc…

Page 15: Learn How To Develop With CakePHP

PHP Frameworks?

Page 16: Learn How To Develop With CakePHP

Model, View, Controller

Tried and true software design pattern that is: Maintainable Modular Ability to rapidly prototype

New features are easily added Separate design allows developers and designers to work

simultaneously Separation allows developers to make changes in one part of

the application without affecting others.

Page 17: Learn How To Develop With CakePHP

Cake PHP Anatomy

Page 18: Learn How To Develop With CakePHP

File and Classname Conventions Filenames are underscored while

classnames are CamelCased So if you have a class MyNiftyClass, then in

Cake, the file should be named my_nifty_class.php

Page 19: Learn How To Develop With CakePHP

Model and Database Conventions

Model classnames are singular and CamelCased.

Table names corresponding to CakePHP models are plural and underscored. people tasks users

Field names with two or more words are underscored like first_name

Foreign keys <singular_table_name>_id

Page 20: Learn How To Develop With CakePHP

Controller Conventions

Controller classnames are plural, CamelCased, and end in Controller.

PeopleController and LatestArticlesController are both examples of conventional controller names.

Page 21: Learn How To Develop With CakePHP

View Conventions

View template files are named after the controller functions they display, in an underscored form.

The getReady() function of the PeopleController class will look for a view template in /app/views/people/get_ready.ctp.

Page 22: Learn How To Develop With CakePHP

Documentation : The Bakery

Page 23: Learn How To Develop With CakePHP

Let’s get started : Installation

http://tinyurl.com/yekjbae

Basic knowledge of PHP Basic knowledge of Databases

You know how to create database tables with MySQL

A working development environment on your Laptop Apache 2.2.x MySQL 5.x PHP 5.3.x or 5.2.x PHPMyAdmin IDE (Any good text editor like

Notepad+, TextMate, Etc) CakePHP 1.2.x

Page 24: Learn How To Develop With CakePHP

What our simple app will do

Keep track of tasks

Create Read Update Delete Created Modified

Page 25: Learn How To Develop With CakePHP

Design the database

Design a DB to hold your data

All tables should include an ID field

Page 26: Learn How To Develop With CakePHP

Bake an app

Design a DB to hold your data

All tables should include an ID field

Page 27: Learn How To Develop With CakePHP

Add more ingredients

Add more data and fields Add users Add status Add validation Add css, and change the

layout Change terminology

Page 28: Learn How To Develop With CakePHP

Some Tips

Create multiple apps all coming from one CakePHP distribution

Model::displayField Scaffolding Layout, and css Localization

__(“string”,true);

Page 29: Learn How To Develop With CakePHP

Thank you

Special thank you to MIT BEER and Food! See you at the next meetup

Contact me [email protected]