SlideShare a Scribd company logo
CakePHP
 新バージョン
   2.0
Graham Weldon

•   PHP developer 11 years

•   CakePHP core
    contributor 4 years

•   Visiting Japan for 3 years
CandyCane
http://my.candycane.jp
•   Recently helping with
    CandyCane

•   Project managed by Ando

•   Lots of good fixes and
    updates made recently

•   Good fun working with
    Japanese developers

• Check it out!
Learning Japanese
•   I am learning Japanese

•   You can speak “very basic”
    Japanese with me

•   But I will have lots of
    problems understanding

•   Please forgive me for any
    mistakes

•   I can write Japanese better
    than I can speak it :-)
CakeFest Conference
•   Manchester, UK

•   4 days!

•   ~100 attendees

•   People from many
    countries

•   Lots of learning

•   Lots of drinking
Overview
Major Points

• No more PHP4
• Refactored throughout
• New Features
• Faster
• New Conventions
PHP5
• 5.2.6+ (Including 5.3)
• Exceptions
• PDO Datasources
• SPL
• Filters
• Support for anonymous functions
Upgrade Console

• Make upgrading simpler
• Do all the tedious work for you
• Automate as much as possible
• Its not perfect
Conventions
File Naming
• MyClass => my_class.php
File Naming
• MyClass => my_class.php
File Naming
• MyClass => my_class.php
• MyClass => MyClass.php
• CamelCased Directories
• “Namespace-ish” separation
• Preparing for PHP 5.3 and PSR-0
File Naming

• Singular directory names
• Model/Behavior/MyBehavior.php
• View/Helper/MyHelper.php
Moved App* Classes


• Model/AppModel.php
• Controller/AppController.php
New Class Loader

• Goodbye to App::import()
• Say Hello to App::uses()

• Similar functionality
• Looks like PHP 5.3 use keyword
App::uses Example
App::uses Example

    App::uses(
       ClassName,
       Package/SubPackage
    );
App::uses Example

    App::uses(
       ClassName,
       Package/SubPackage
    );
App::uses Example

    App::uses(
       ClassName,
       Package/SubPackage
    );
Configuring Packages

• Use App::build() to define where packages
  are located
• Defaults to app/Lib
• Core provides defaults
App::build()

• App::PREPEND
• App::APPEND
• Control your insertion order
• Greater flexibility
Exceptions and
    Errors
cakeError()

• No more cakeError()
• Replaced
 • Exceptions
 • Exception Handlers
• Much better!
Benefits

• Extensible error handling
• Common sense default exceptions
• Configurable handling
• PHP 5.3 awesomeness (if you want)
Custom Rendering
PHP 5.3?
We’re web developers

• HTTP Exceptions
• Named as you would expect
• CakeException for development errors
 • Shows as Error 500 in production
HTTP Exceptions


• All the common HTTP Errors are built in
• Renderer handles display and output
Example
Internationalization
I18n Shortcut

• Simpler
• Returns by default
• Automatic sprintf() functionality
Return by default
• CakePHP 1.x
Return by default
• CakePHP 1.x


• CakePHP 2+
sprintf() built in
• CakePHP 1.x
sprintf() built in
• CakePHP 1.x


• CakePHP 2+
Collections
CakePHP 1.x
• Previously all extensions worked differently
 • Helpers
 • Behaviors
 • Components
 • Tasks
• No common interface / API
CakePHP 2.x

• Collection objects to manage them
• HelperCollection, TaskCollection,
  BehaviorCollection, ComponentCollection
• Similar functionality, same API
• Easy to use and extend
Responsibilities

• Load objects when required
• Unload objects
• Alias objects
• Manage callbacks
Object Loading

• $this->Html now available
• The same API exists for other collections:
 • Behaviors
 • Components
 • Tasks
Aliasing

• Handy for providing custom functionality
• Used to be annoying to “override” defaults
• Possible, but not an elegant solution
CakePHP 1.x
CakePHP 2.x
Global usage

• Once an alias is defined, its used
  everywhere
• Anything else accessing $this->Auth would
  use CustomAuthComponent
More control
     with Collections
• Unload

• Disable

• Enable
Console
Console Changes
• Console now has a home
   • app/Console
• Coloured output
• Better input handling
• Generated help
• Various output formats
Colour
• Simple markup to colourise your output
    • Warning
    • Error
    • Info
    • Question
    • ... and more
Simple markup
Colour
Auto-Generated Help

• Writing documentation sucks
• Using the ConsoleOptionParser gives you
  help for free
• Simple to use
• Two birds with one stone
ConsoleOptionParser
Request
   &
Response
CakeRequest
• All request information in a single place
• Use $this->request everywhere
• Memory use is lower
   • No more copies of copies of copies of
      arrays all over the place
• Backwards compatible interface
CakeResponse

• Again, consolidate logic to a single location
• Use $this->response everywhere
• Backwards compatibility provided
Sessions
Sessions
• Remove duplicated code (DRY)
• Shouldn’t be always included (1.3 fix)
• Modelise data handling
• Access anywhere
• Allow simple customisation
• Separate Caching, Database, etc.
Sessions
           SessionHandler


Database       Cache        PHP
Sessions
           SessionHandler


Database       Cache        PHP
Sessions
           SessionHandler


Database       Cache          PHP


           My Custom Engine
Sessions
           SessionHandler


Database       Cache              PHP
                                Cake
                               Session
           My Custom Engine    Handler
                              Interface
Authentication
Authorization
AuthComponent
       AuthComponent


Authentication   Authorization
AuthComponent

• No more magic logins
• No more magic hashing
• Easier to understand the workflow
• Easier to extend
• Easier to modify
Authentication

• Form
• HTTP Basic
• HTTP Digest
• Custom
Authorization

• Controller
• Action (ACL)
• CRUD (ACL)
• Custom
Example Login
Email
EmailComponent

• No longer a component
• Set of separate classes
• Easily used from Models and Consoles
• Component is deprecated
Email Example
Email Example
 In Models!
Unit Testing
Unit Testing
• PHPUnit is the de-facto standard for PHP
• SimpleTest has less features
• SimpleTest was not PHP5 ready when we
  started
• PHPUnit offers greater features
• More flexibility in testing
Performance
Performance

• All round increases in performance
   • Lazy Loading
   • New Conventions => Less Inflector
   • Simpler dispatch
   • Persistent DBO cache
Benchmark
   “Hello World”




Benchmarks courtesy of Mark Story
Benchmark
     “Basic Blog”




Benchmarks courtesy of Mark Story
Resources
    &
  Links
CakePHP 2
      Documentation
• Book for CakePHP 2
   • http://book.cakephp.org/2.0/ja/
   • We need help for Japanese!
   • Hiromi helping
CakePHP 2
             API
• API is already available
   • http://api20.cakephp.org
• Updated every time a build succeeds
• Automated + up to date
CakePHP 2
Continuous Integration
• We are using Jenkins
• Automated builds and reporting
• Better quality framework
• Consistent testing
• http://ci.cakephp.org
質問はありますか?
ありがとう

More Related Content

KEY
CakePHP - The Path to 2.0
KEY
Re-imaginging CakePHP
PDF
PHP 5.4 - Begin your love affair with traits
KEY
SydPHP March 2012 Meetup
PDF
An introduction to Titanium
PPS
Moving Pictures - Web 2.0 Expo NYC
PDF
Myphp-busters: symfony framework
PDF
Myphp-busters: symfony framework (PHPCon.it)
CakePHP - The Path to 2.0
Re-imaginging CakePHP
PHP 5.4 - Begin your love affair with traits
SydPHP March 2012 Meetup
An introduction to Titanium
Moving Pictures - Web 2.0 Expo NYC
Myphp-busters: symfony framework
Myphp-busters: symfony framework (PHPCon.it)

What's hot (20)

PDF
2021laravelconftwslides6
PPTX
PHP and Platform Independance in the Cloud
PDF
Cfml features modern_coding
PPT
Coldfusion
 
PDF
A look at FastCgi & Mod_PHP architecture
KEY
SydPHP May 2012 - Deployment
PDF
mod_php vs FastCGI vs FPM vs CLI
PPTX
Upstate CSCI 450 PHP Chapters 5, 12, 13
PDF
Securing Legacy CFML Code
PPS
Scalable PHP
PPTX
10 Reasons ColdFusion PDFs should rule the world
PDF
Command Box ColdFusion Package Manager, Automation
PPTX
Performance tips for Symfony2 & PHP
PDF
Hack & Fix, Hands on ColdFusion Security Training
PPTX
Getting started with PHP on IBM i
PDF
Can you contain the future - Docker, Container Technologies, The Future, and You
PDF
CommandBox & ForgeBox Package Management
PDF
Locking Down CF Servers
PDF
High Performance Solution for PHP7
PDF
PHP7.1 New Features & Performance
2021laravelconftwslides6
PHP and Platform Independance in the Cloud
Cfml features modern_coding
Coldfusion
 
A look at FastCgi & Mod_PHP architecture
SydPHP May 2012 - Deployment
mod_php vs FastCGI vs FPM vs CLI
Upstate CSCI 450 PHP Chapters 5, 12, 13
Securing Legacy CFML Code
Scalable PHP
10 Reasons ColdFusion PDFs should rule the world
Command Box ColdFusion Package Manager, Automation
Performance tips for Symfony2 & PHP
Hack & Fix, Hands on ColdFusion Security Training
Getting started with PHP on IBM i
Can you contain the future - Docker, Container Technologies, The Future, and You
CommandBox & ForgeBox Package Management
Locking Down CF Servers
High Performance Solution for PHP7
PHP7.1 New Features & Performance
Ad

Viewers also liked (7)

PDF
Re-imagining CakePHP (OSDC 2010)
KEY
Building 3D apps with Javascript
KEY
CakePHP and Open Source - Newcastle University
KEY
The business behind open source
KEY
SydPHP April 2012
ODP
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
PDF
Optimizing CakePHP 2.x Apps
Re-imagining CakePHP (OSDC 2010)
Building 3D apps with Javascript
CakePHP and Open Source - Newcastle University
The business behind open source
SydPHP April 2012
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Optimizing CakePHP 2.x Apps
Ad

Similar to CakePHP 2.0 - PHP Matsuri 2011 (20)

PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
PPTX
Php internal architecture
PPTX
ExpressionEngine - Simple Steps to Performance and Security (EECI 2014)
PPTX
They why behind php frameworks
PDF
Intro to CakePHP
PDF
Stress Free Deployment - Confoo 2011
PPTX
Caching strategies with lucee
PDF
Top ten-list
PDF
DanNotes 2013: OpenNTF Domino API
PDF
Zend Framework 2, What's new, Confoo 2011
PDF
Modern Functional Fluent CFML REST by Luis Majano
PPTX
Continuous feature-development
PPTX
Tuenti Release Workflow
PDF
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
PDF
Configuration manager presentation
PDF
Beyond Domino Designer
PPT
PDF
presentation
PDF
Add-On Development: EE Expects that Every Developer will do his Duty
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Php internal architecture
ExpressionEngine - Simple Steps to Performance and Security (EECI 2014)
They why behind php frameworks
Intro to CakePHP
Stress Free Deployment - Confoo 2011
Caching strategies with lucee
Top ten-list
DanNotes 2013: OpenNTF Domino API
Zend Framework 2, What's new, Confoo 2011
Modern Functional Fluent CFML REST by Luis Majano
Continuous feature-development
Tuenti Release Workflow
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
Configuration manager presentation
Beyond Domino Designer
presentation
Add-On Development: EE Expects that Every Developer will do his Duty

More from Graham Weldon (9)

PDF
HackLang Introduction
PPT
20130714 php matsuri - highly available php
KEY
SydPHP June 2012 - GovHack overview
KEY
MySQL Performance - SydPHP October 2011
KEY
Nginx in production
KEY
CakePHP 2.0 - It'll rock your world
PDF
CakePHP Tutorial - OSDC 2010
PDF
Debugging and Profiling PHP
PDF
OSDC LIghtning Talk - Context Free Art
HackLang Introduction
20130714 php matsuri - highly available php
SydPHP June 2012 - GovHack overview
MySQL Performance - SydPHP October 2011
Nginx in production
CakePHP 2.0 - It'll rock your world
CakePHP Tutorial - OSDC 2010
Debugging and Profiling PHP
OSDC LIghtning Talk - Context Free Art

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Approach and Philosophy of On baking technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
MYSQL Presentation for SQL database connectivity
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
Review of recent advances in non-invasive hemoglobin estimation

CakePHP 2.0 - PHP Matsuri 2011

Editor's Notes

  • #2: \n
  • #3: \n
  • #4: - I have recently been contributing to the CandyCane project\n- Its a great opportunity to work with japanese developers\n
  • #5: - I am learning japanese\n- People can try and talk to me in Japanese\n- I will probably have too much trouble understanding\n- Best to stick to English\n- I can write Japanese better than I can speak Japanese\n
  • #6: \n
  • #7: \n
  • #8: \n
  • #9: \n
  • #10: \n
  • #11: \n
  • #12: \n
  • #13: \n
  • #14: \n
  • #15: \n
  • #16: \n
  • #17: \n
  • #18: \n
  • #19: \n
  • #20: \n
  • #21: \n
  • #22: \n
  • #23: \n
  • #24: \n
  • #25: \n
  • #26: \n
  • #27: \n
  • #28: \n
  • #29: \n
  • #30: \n
  • #31: \n
  • #32: \n
  • #33: - Ask who in the audience has worked on a moderate sized application with translation capabilities\n- Mention how messy code can get when you have lots of shortcut usage in view files\n
  • #34: - We have made the “double underscore” shortcut function return the result by default\n- Previously it would echo out the result, unless you supplied “true” as the second parameter\n- This makes __() usage shorter\n
  • #35: \n
  • #36: - If you wanted to inject values into a tranlated string, you need to use sprintf()\n- This lets you provide a translatable string, without hard coding data that changes\n- We now provide sprintf functionality inside the “double underscore” shortcut function\n- Makes code easier to read and maintain\n
  • #37: \n
  • #38: \n
  • #39: \n
  • #40: \n
  • #41: \n
  • #42: \n
  • #43: \n
  • #44: - If you wanted to provide a custom Authentication component\n- You have to hack in the “Auth” variable on the controller instance\n- Not very flexible\n
  • #45: - CakePHP 2 allows you to “alias” an object.\n- Here we use the “CustomAuthComponent” with the instance variable name “Auth”\n- Just defined the className for Auth at the Controller level\n
  • #46: \n
  • #47: \n
  • #48: \n
  • #49: \n
  • #50: \n
  • #51: \n
  • #52: - Example output\n
  • #53: - Writing documentation can be a tedious job\n- The option parser can generate console help for users\n
  • #54: \n
  • #55: \n
  • #56: - Copying arrays uses a lot of memory if its done a large number of times\n- We’re referencing an object instead of duplicating arrays\n- Yields memory consumption benefits\n
  • #57: \n
  • #58: \n
  • #59: \n
  • #60: \n
  • #61: \n
  • #62: \n
  • #63: \n
  • #64: \n
  • #65: \n
  • #66: - Was very tightly coupled\n- Separate adapters now\n- Easier to modify and extend\n
  • #67: \n
  • #68: - Built in Authentication mechanisms\n
  • #69: \n
  • #70: - Need to do login checking within the app\n- Its a couple of extra lines\n- Not too bad, given how easy it is to customise now\n
  • #71: \n
  • #72: \n
  • #73: \n
  • #74: \n
  • #75: \n
  • #76: \n
  • #77: \n
  • #78: \n
  • #79: \n
  • #80: \n
  • #81: \n
  • #82: \n
  • #83: \n
  • #84: \n
  • #85: \n
  • #86: \n