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

What's hot (20)

PDF
2021laravelconftwslides6
LiviaLiaoFontech
 
PPTX
PHP and Platform Independance in the Cloud
ZendCon
 
PDF
Cfml features modern_coding
ColdFusionConference
 
PPT
Coldfusion
Ram
 
PDF
A look at FastCgi & Mod_PHP architecture
Aimee Maree
 
KEY
SydPHP May 2012 - Deployment
Graham Weldon
 
PDF
mod_php vs FastCGI vs FPM vs CLI
Jacques Woodcock
 
PPTX
Upstate CSCI 450 PHP Chapters 5, 12, 13
DanWooster1
 
PDF
Securing Legacy CFML Code
ColdFusionConference
 
PPS
Scalable PHP
Cal Henderson
 
PPTX
10 Reasons ColdFusion PDFs should rule the world
ColdFusionConference
 
PDF
Command Box ColdFusion Package Manager, Automation
ColdFusionConference
 
PPTX
Performance tips for Symfony2 & PHP
Max Romanovsky
 
PDF
Hack & Fix, Hands on ColdFusion Security Training
ColdFusionConference
 
PPTX
Getting started with PHP on IBM i
Zend by Rogue Wave Software
 
PDF
Can you contain the future - Docker, Container Technologies, The Future, and You
ColdFusionConference
 
PDF
CommandBox & ForgeBox Package Management
Ortus Solutions, Corp
 
PDF
Locking Down CF Servers
ColdFusionConference
 
PDF
High Performance Solution for PHP7
Xinchen Hui
 
PDF
PHP7.1 New Features & Performance
Xinchen Hui
 
2021laravelconftwslides6
LiviaLiaoFontech
 
PHP and Platform Independance in the Cloud
ZendCon
 
Cfml features modern_coding
ColdFusionConference
 
Coldfusion
Ram
 
A look at FastCgi & Mod_PHP architecture
Aimee Maree
 
SydPHP May 2012 - Deployment
Graham Weldon
 
mod_php vs FastCGI vs FPM vs CLI
Jacques Woodcock
 
Upstate CSCI 450 PHP Chapters 5, 12, 13
DanWooster1
 
Securing Legacy CFML Code
ColdFusionConference
 
Scalable PHP
Cal Henderson
 
10 Reasons ColdFusion PDFs should rule the world
ColdFusionConference
 
Command Box ColdFusion Package Manager, Automation
ColdFusionConference
 
Performance tips for Symfony2 & PHP
Max Romanovsky
 
Hack & Fix, Hands on ColdFusion Security Training
ColdFusionConference
 
Getting started with PHP on IBM i
Zend by Rogue Wave Software
 
Can you contain the future - Docker, Container Technologies, The Future, and You
ColdFusionConference
 
CommandBox & ForgeBox Package Management
Ortus Solutions, Corp
 
Locking Down CF Servers
ColdFusionConference
 
High Performance Solution for PHP7
Xinchen Hui
 
PHP7.1 New Features & Performance
Xinchen Hui
 

Viewers also liked (7)

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

Similar to CakePHP 2.0 - PHP Matsuri 2011 (20)

PDF
Ch ch-changes cake php2
markstory
 
PDF
CakePHP 3.0: Embracing the future
José Lorenzo Rodríguez Urdaneta
 
KEY
CakePHP 2.0 - It'll rock your world
Graham Weldon
 
PPTX
cakephp UDUYKTHA (1)
Varsha Krishna
 
PDF
CakePHP
Walther Lalk
 
PDF
Intro to CakePHP
Walther Lalk
 
PPTX
Trusted PHP Development Services in the USA
TechnoProfiles Pvt. Ltd.
 
KEY
Pluginize ALL the things
Jose Diaz-Gonzalez
 
DOC
How to migrate Cakephp 1.x to 2.x
Andolasoft Inc
 
PDF
4 introduction-php-mvc-cakephp-m4-controllers-slides
MasterCode.vn
 
PDF
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
JPLoft Solutions
 
PPTX
Ei cakephp
eiei lay
 
PPTX
Cakeph pppt
Wizard Rider
 
PPT
Intro to CakePHP 1.3
Adam Culp
 
PPT
Synapseindia reviews sharing intro cakephp
SynapseindiaComplaints
 
PDF
5503 cake php-tutorial-no-1-from-ibm
balajipala
 
PPT
Introduction to Cakephp
Aditya Mooley
 
ODP
PHP South Coast - Don't code bake, an introduction to CakePHP 3
David Yell
 
KEY
Really Rapid Admin Application Development
Jose Diaz-Gonzalez
 
PDF
Introduction to CakePHP
mohamedsamirgalal
 
Ch ch-changes cake php2
markstory
 
CakePHP 3.0: Embracing the future
José Lorenzo Rodríguez Urdaneta
 
CakePHP 2.0 - It'll rock your world
Graham Weldon
 
cakephp UDUYKTHA (1)
Varsha Krishna
 
CakePHP
Walther Lalk
 
Intro to CakePHP
Walther Lalk
 
Trusted PHP Development Services in the USA
TechnoProfiles Pvt. Ltd.
 
Pluginize ALL the things
Jose Diaz-Gonzalez
 
How to migrate Cakephp 1.x to 2.x
Andolasoft Inc
 
4 introduction-php-mvc-cakephp-m4-controllers-slides
MasterCode.vn
 
Why CakePHP Is Superior to Other Web Frameworks! Examine Its Pros & Cons For ...
JPLoft Solutions
 
Ei cakephp
eiei lay
 
Cakeph pppt
Wizard Rider
 
Intro to CakePHP 1.3
Adam Culp
 
Synapseindia reviews sharing intro cakephp
SynapseindiaComplaints
 
5503 cake php-tutorial-no-1-from-ibm
balajipala
 
Introduction to Cakephp
Aditya Mooley
 
PHP South Coast - Don't code bake, an introduction to CakePHP 3
David Yell
 
Really Rapid Admin Application Development
Jose Diaz-Gonzalez
 
Introduction to CakePHP
mohamedsamirgalal
 
Ad

More from Graham Weldon (8)

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

Recently uploaded (20)

PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Python basic programing language for automation
DanialHabibi2
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 

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