19. Built-in exceptions
All previous Object::cakeError() are
exceptions.
Improved testing.
Suite of HTTP exceptions. Great for error
pages.
CakeException for development errors.
Treated as 500 errors in production.
20. HTTP Exceptions
Most common HTTP exceptions are built in.
The names are what you would expect.
Configured Exception handler will get the
exceptions and render an error page.
21. HttpExceptions
1 <?php
2 public function view($id = null) {
3 $this->Tag->id = $id;
4 if (!$this->Tag->exists()) {
5 throw new NotFoundException(__('Invalid tag'));
6 }
7 $this->set('tag', $this->Tag->read(null, $id));
8 }
22. Error Configuration
Configure used for error/exception settings.
Sensible defaults.
Uses Debugger in development
Logs errors in production.
You can change out the whole thing.
27. Unify & syngergize
Helper, Components, Behaviors & Tasks.
Similar, but interacting with each was slightly
different.
Collection objects unify all of them.
HelperCollection, ComponentCollection,
TaskCollection, BehaviorCollection
31. Aliasing
Once an alias is created, that alias is used
everywhere.
With the above controller code, all other
Helpers would use MyHtmlHelper for
$this->Html.
35. Console
improvements
Coloured output & output levels.
Less coupled & easier to test.
Better input handling.
Generated help.
XML help. Good for integration with other
tools.
36. COLORZ
Simple formatting to add styles to output.
$this->out(‘<warning>Uh oh</warning>’);
$this->out(‘<error>Kaboom</error>’);
$this->out(‘<info>Hi</info>’, 1, Shell::VERBOSE);
37. Input handling
More unix-y input handling.
Long and short options.
Validated options.
Boolean options.
Required arguments.
38. Generated help
Defining command structure with
ConsoleOptionParser means you get help for
free.
--help and -h supported by all shells.
--help xml generates xml help.
40. CakeRequest
Consolidates request interrogation logic.
$this->request everywhere.
Lower memory use by not copying arrays
everywhere.
Backwards compatible read only interface
still around.
45. Sessions
Core, App, and Plugin session handlers all
work the same.
CakeSessionInterface interface has to be
implemented.
Same built-in options exist.
54. Email
Decomposed into several classes.
Email is easily accessible from models &
shells.
EmailComponent is deprecated, because it
doesn’t really add anything at this point.
55. Simple Example
1 <?php
2 App::uses('CakeEmail', 'Network/Email');
3 $mail = new CakeEmail();
4 $mail->from('mark.story@gmail.com', 'Mark Story')
5 ->to('steve@apple.com', 'Steve Jobs')
6 ->subject('Love the new imacs')
7 ->send('I <3 you so much.');
59. Testing
PHPUnit is the de-facto standard.
SimpleTest is less feature rich, and didn’t
have a PHP5 compatible version when we
started.
Tune in for my talk on PHPUnit.
61. All win
Lazy loading everywhere it made sense.
Components, helpers, associated models.
Removed most getInstance() methods.
New conventions mean less Inflector calls.
Streamlined dispatch cycle.
Persistent dbo cache.