cakephp 3.0: embracing the future

40
CakePHP 3.0 Embracing the future

Upload: jose-lorenzo-rodriguez

Post on 17-May-2015

7.033 views

Category:

Technology


4 download

DESCRIPTION

Talk presented during PHP Matsuri 2012 in Fukuoka, Japan about the planned features and changes for CakePHP 3.0

TRANSCRIPT

Page 1: CakePHP 3.0: Embracing the future

CakePHP 3.0Embracing the future

Page 2: CakePHP 3.0: Embracing the future

About me@jose_zap

Page 3: CakePHP 3.0: Embracing the future

I love scuba diving

Page 4: CakePHP 3.0: Embracing the future

And enjoy all sorts of extreme

Like rock climbing

Page 5: CakePHP 3.0: Embracing the future

or rafting

Page 6: CakePHP 3.0: Embracing the future

and Sky diving

Page 7: CakePHP 3.0: Embracing the future

7 years ago...

PHP 4.3 was king

PHP 5.1 was about to be released

There was no PDO, no json extension by default, no unicode and no SPL

Object orientation was very immature and buggy in PHP

No actual frameworks on the market, there was xoops and mojavi (?)

Page 8: CakePHP 3.0: Embracing the future

7 years ago...

CakePHP is released to the public to fix ALL THE THINGS

Page 9: CakePHP 3.0: Embracing the future

A pioneer in PHP land

MVC

Convention over configuration

Object oriented

Active record like database abstraction

Secure by default

Page 10: CakePHP 3.0: Embracing the future

Always innovating...

Unit testing

PHP implementation of multibyte extension

Command line php shells

Plugins!

Reverse routing

Behaviors, Form helper, pagination, caching, i18n and much more

2008

Page 11: CakePHP 3.0: Embracing the future

We made it flexible

Pluggable logging system

Caching, session and javascript engines

Localized validation

Routing with custom classes

Configurable paths

2010

Page 12: CakePHP 3.0: Embracing the future

Even more flexible and reliable!

PHP 5.2

Customizable error handlers

Pluggable Auth component and email system

PHPUnit

PDO

Request and Response objects

2011

Page 13: CakePHP 3.0: Embracing the future

Even more feature rich yet faster

View blocks

Content-type aware view classes

Easier HTTP caching

Configuration engines

Middleware (Dispatcher filters)

Generic events system

2012

Page 14: CakePHP 3.0: Embracing the future

Coming soon..

CakePHP 2.3

PHP 5.4 local server

Better encryption strategies for authentication

Tons of small fixes that will just make you happier

2012

Page 15: CakePHP 3.0: Embracing the future

An increasing debt...

Model layer is basically the same since PHP 4

No namespace support

Inflexible in some parts due to original PHP object restrictions

It could be faster

Sometimes encourages bad coding practices

Page 16: CakePHP 3.0: Embracing the future

Time to go back to the future

Page 17: CakePHP 3.0: Embracing the future

Who needs PHP 5.3?

Let’s go with 5.4 all the way!

Page 18: CakePHP 3.0: Embracing the future

PHP 5.4, what we’re after

Traits, they seem like a good way of implementing behaviors

Closure binding, an alternative way of injecting finders or more behaviors

JsonSerializable interface, easier web services

It’s faster!

Page 19: CakePHP 3.0: Embracing the future

Adopt namespaces

Page 20: CakePHP 3.0: Embracing the future

We will keep as much as possible our current way of addressing to class names (using conventions and dot notation)

Already prepared for this moment in 2.0, we are just replacing App::uses() with native “use” statements

Classes will keep their suffixes, for instances PostsController will still be named the same instead of just “Posts”

We hate the wrong slash (\)

Page 21: CakePHP 3.0: Embracing the future

Configuration Changes

Page 22: CakePHP 3.0: Embracing the future

More freedom and clarity for you

Unified configuration: No more Cache::config(), everything is setup in the Configure class now

Remove obscurity and still use conventions. Each step of the bootstrapping process will be handled in a separate file

Page 23: CakePHP 3.0: Embracing the future

Example bootstrap.php file

Page 24: CakePHP 3.0: Embracing the future

Example cache.php file

Page 25: CakePHP 3.0: Embracing the future

Improved and faster routing

Page 26: CakePHP 3.0: Embracing the future

Time to cut the fat

Named params are going to be removed (no more /var:value/)

Ability to set ssl, scheme, host and port in router calls

Named routes for faster lookups

Prefix routing to map subclasses

Constant reverse routing time

Page 27: CakePHP 3.0: Embracing the future

Prefixed actions

No more mixing admin and non admin actions in the same class

Prefixed routing will map to classes inside a namespace

Instead of UsersController::admin_index() you will have App\Controller\Admin\UsersController::index()

Page 28: CakePHP 3.0: Embracing the future

Routing example

Page 29: CakePHP 3.0: Embracing the future

New database layer

Page 30: CakePHP 3.0: Embracing the future

Current problems...

Frankenstein models. Is it a record or a table?

Inconsistent API. Model::read() vs. Model::find()

No Query object, only arrays

No Record object

Recursive and Containable should be kissed good bye

DboSource is dependent on the models and viceversa

Page 31: CakePHP 3.0: Embracing the future

A shiny new database layer

Clean separation of concerns: database layer should be usable on its own

Create a rich query builder

Intelligent data types. Cross database support for database data types (bigint, uuid, datetime, array, etc.)

Pluggable. Most aspect of this layer should swappable with custom classes

Page 32: CakePHP 3.0: Embracing the future

Usable connection object

Page 33: CakePHP 3.0: Embracing the future

Custom data types

Page 34: CakePHP 3.0: Embracing the future

Query Object

Page 35: CakePHP 3.0: Embracing the future

Table Objects

Will represent the database table/collection

Responsible for actually persisting, finding, deleting records

Schema can be declared and managed here

Can be optionally created (a default object is used instead)

Will be very similar to what current CakePHP models are now

Page 36: CakePHP 3.0: Embracing the future

Record objects

Access record data

Provide getters and setters

Access associated model data

Save, delete and update themselves

Validation

Page 37: CakePHP 3.0: Embracing the future

Putting it all together

Page 38: CakePHP 3.0: Embracing the future

Using records

Page 39: CakePHP 3.0: Embracing the future

Model behaviors will be traits

Callbacks, some are table level others record level

Saving on associated objects

Undecided...

Page 40: CakePHP 3.0: Embracing the future

We need your helpto deliver faster