This document provides an overview of some of the key changes and new features being introduced in CakePHP 2.0. Some of the major changes discussed include: refactoring the core codebase and removing unused code; upgrading to PHPUnit for unit testing; standardizing how objects inherit via new Component architecture; leveraging more of the Standard PHP Library; exceptions being used to indicate errors; centralizing request and response handling; and dropping support for PHP 4. New features highlighted include PDO database support, simplified URL rewriting, support for nested named parameters, and a refactored authentication system. The document also discusses some of the challenges faced, including retaining backwards compatibility while continuing to improve and modernize the framework.
10. ... its been a year
We talked about CakePHP 2.0 at
CakeMatsuri in 2009
11. ... its been a year
We talked about CakePHP 2.0 at
CakeMatsuri in 2009
Instead of releasing CakePHP 2.0 that “just
works” with PHP5
12. ... its been a year
We talked about CakePHP 2.0 at
CakeMatsuri in 2009
Instead of releasing CakePHP 2.0 that “just
works” with PHP5
Refactoring the core
13. ... its been a year
We talked about CakePHP 2.0 at
CakeMatsuri in 2009
Instead of releasing CakePHP 2.0 that “just
works” with PHP5
Refactoring the core
Exciting changes instead of a quick fix
14. ... its been a year
We talked about CakePHP 2.0 at
CakeMatsuri in 2009
Instead of releasing CakePHP 2.0 that “just
works” with PHP5
Refactoring the core
Exciting changes instead of a quick fix
Look at code that has been around for 4+
years
15. ... its been a year
We talked about CakePHP 2.0 at
CakeMatsuri in 2009
Instead of releasing CakePHP 2.0 that “just
works” with PHP5
Refactoring the core
Exciting changes instead of a quick fix
Look at code that has been around for 4+
years
Remove a lot of code thats no longer
needed
19. Challenges
Retain older users and backwards
compatibility
Move forward and adopt new features
Stay true to the projects goals and ideals
20. Challenges
Retain older users and backwards
compatibility
Move forward and adopt new features
Stay true to the projects goals and ideals
Rattle some cages
21. Challenges
Retain older users and backwards
compatibility
Move forward and adopt new features
Stay true to the projects goals and ideals
Rattle some cages
... not too many.
49. Unit Testing
Arguably one of the bigger changes
PHPUnit
Provides better PHP 5 support over
SimpleTest
50. Unit Testing
Arguably one of the bigger changes
PHPUnit
Provides better PHP 5 support over
SimpleTest
More actively maintained
51. Unit Testing
Arguably one of the bigger changes
PHPUnit
Provides better PHP 5 support over
SimpleTest
More actively maintained
Easily integrated with CruiseControl
52. Unit Testing
Arguably one of the bigger changes
PHPUnit
Provides better PHP 5 support over
SimpleTest
More actively maintained
Easily integrated with CruiseControl
De-facto standard for Unit Testing in PHP
53. Unit Testing
Arguably one of the bigger changes
PHPUnit
Provides better PHP 5 support over
SimpleTest
More actively maintained
Easily integrated with CruiseControl
De-facto standard for Unit Testing in PHP
Install with PEAR
54. Unit Testing
Arguably one of the bigger changes
PHPUnit
Provides better PHP 5 support over
SimpleTest
More actively maintained
Easily integrated with CruiseControl
De-facto standard for Unit Testing in PHP
Install with PEAR
Faster
65. Unit Testing
PHPUnit, at what cost?
Rewritten test suite from the ground up
Mocks are different.. but awesome++
66. Unit Testing
PHPUnit, at what cost?
Rewritten test suite from the ground up
Mocks are different.. but awesome++
startTest() and endTest() deprecated
67. Unit Testing
assertions slightly different
Backwards compatibility provided
Example:
$this->assertEqual
Now:
$this->assertEquals
75. Components
What does this mean in the scheme of
things?
We’ve standardised the manner in which
objects inherit
76. Components
What does this mean in the scheme of
things?
We’ve standardised the manner in which
objects inherit
Makes more sense
77. Components
What does this mean in the scheme of
things?
We’ve standardised the manner in which
objects inherit
Makes more sense
Intuitive
78. Components
What does this mean in the scheme of
things?
We’ve standardised the manner in which
objects inherit
Makes more sense
Intuitive
Less need to search documentation
80. SPL
Standard PHP Library
Provides awesome File and Folder
operations
Classes handy for a whole range of things
No need to re-implement in the core
CakePHP 1.x was ahead of its time
PHP has caught up
Time to cut the fat
81. Non-SPL
Again, don’t reinvent the wheel
Removing duplicate code like JSON
encoding
Can now rely on this functionality shipping
with PHP
84. Exceptions
Create custom handlers for each exception
Control what happens after an exception
Example:
MediaView
If file not found:
Handle intelligently
86. Request / Response
Request represents an incoming request
It replaces functionality through Controller,
Dispatcher, RequestHandler and $this-
>params everywhere
ArrayAccess implementation for backwards
compatibility
87. Request / Response
Protect users form themselves
Protect developers from users
Protect developers from stupidity
Encapsulate both the request and response
in order to provide a central location to
handle requests and responses, but retain
flexibility
89. 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.
105. XML
As much as one can make XML make sense..
.. we’re doing it
106. XML
As much as one can make XML make sense..
.. we’re doing it
1.x was very CakePHP specific with XML
107. XML
As much as one can make XML make sense..
.. we’re doing it
1.x was very CakePHP specific with XML
Wasn’t handy for integration
108. XML
As much as one can make XML make sense..
.. we’re doing it
1.x was very CakePHP specific with XML
Wasn’t handy for integration
Didn’t handle namespaces well
109. XML
As much as one can make XML make sense..
.. we’re doing it
1.x was very CakePHP specific with XML
Wasn’t handy for integration
Didn’t handle namespaces well
Didn’t allow for ordered nodes
110. XML
As much as one can make XML make sense..
.. we’re doing it
1.x was very CakePHP specific with XML
Wasn’t handy for integration
Didn’t handle namespaces well
Didn’t allow for ordered nodes
111. XML
As much as one can make XML make sense..
.. we’re doing it
1.x was very CakePHP specific with XML
Wasn’t handy for integration
Didn’t handle namespaces well
Didn’t allow for ordered nodes
Build on top of SimpleXML
112. XML
As much as one can make XML make sense..
.. we’re doing it
1.x was very CakePHP specific with XML
Wasn’t handy for integration
Didn’t handle namespaces well
Didn’t allow for ordered nodes
Build on top of SimpleXML
Faster
118. Console
Easier help generation
Better for users of plugins, as well as
plugin developers
Colourised console text
Easy identification of issues and errors
119. Console
Easier help generation
Better for users of plugins, as well as
plugin developers
Colourised console text
Easy identification of issues and errors
Support output verbosity
120. Console
Easier help generation
Better for users of plugins, as well as
plugin developers
Colourised console text
Easy identification of issues and errors
Support output verbosity
Shells are being used:
121. Console
Easier help generation
Better for users of plugins, as well as
plugin developers
Colourised console text
Easy identification of issues and errors
Support output verbosity
Shells are being used:
restructure: app/console/
122. Console
Easier help generation
Better for users of plugins, as well as
plugin developers
Colourised console text
Easy identification of issues and errors
Support output verbosity
Shells are being used:
restructure: app/console/
Moved from: app/vendors/
123. Console
Easier help generation
Better for users of plugins, as well as
plugin developers
Colourised console text
Easy identification of issues and errors
Support output verbosity
Shells are being used:
restructure: app/console/
Moved from: app/vendors/
Enable better console path configurability
131. Email
Used to be restricted to Controller use with
a Component
... or a terrible hack to enable it elsewhere
132. Email
Used to be restricted to Controller use with
a Component
... or a terrible hack to enable it elsewhere
Now its a core lib
133. Email
Used to be restricted to Controller use with
a Component
... or a terrible hack to enable it elsewhere
Now its a core lib
Use it anywhere
134. Email
Used to be restricted to Controller use with
a Component
... or a terrible hack to enable it elsewhere
Now its a core lib
Use it anywhere
Wrappers to provide model / controller use
135. Email
Used to be restricted to Controller use with
a Component
... or a terrible hack to enable it elsewhere
Now its a core lib
Use it anywhere
Wrappers to provide model / controller use
Simple, and effective
138. PDO
Yes, dear God yes!
PDO datasources now available in 2.0
Working with Microsoft to get MSSQL
support finalised with new PDO drivers
139. PDO
All databases work the same
Easily switch between engines
Provides assurance for context switching:
Development Environment
Production Environment