Story of CakePHP 2.0 2011.1.17 The New Year CakePHP Study in Tokyo
About  M e Name : Shimizu  Hiroki( hiromi2424 ) Job : Web  Developer(Freelance) L ibraries : github ( Transition ,  ModularAuth ) W ork : Translation H obby : S inging, Beer!!!
Introduction
CakePHP 2.0 has large number of enhancements It is no longer same thing compared with 1.x But there are many compatible stuff Most of libraries and applications also can be migrated easily Introduction
Summary Decoupling & Delegeting Request & Response Auth Loading Object On The Fly Others Various Problems Resolved Security Component Pagination More Flexible Routes Lazy Loading Conclusion
Decoupling & Delegeting
Decoupling & Delegeting Current Requst handling Request & Response Lose Consistency Hard to Test Ugly Workaround Impossible to Inherit
Decoupling & Delegeting Requst handling in CakePHP 2.0 Request & Response Same Object Common API Parse Request Convenient Method
Decoupling & Delegeting In Your Controller or so $this-> request ->here $this->params['prefix'] // also accesible but  deprecated $this-> request -> data (' User.name '); // returns name $this->request->data('User.ip_address', $this-> request -> clientIp () ); Request & Response
Decoupling & Delegeting Response Handling in CakePHP 2.0 Request & Response All of handling HTTP response would be  done through Response object Helps Media Rendering Download HTTP Systems
Decoupling & Delegeting Auth's Responsibility was too heavy Auth Validating Post Login Login/Logout Handling Loading Current User Various Autorization Pattern DarkAuth OpenID  and  OAuth
Decoupling & Delegeting Auth will be separated Auth Authentication  and  Authorization Basic ,  Digest  Authentication is already available Core Team giving a try to support  OpenID
Decoupling & Delegeting ObjectCollection is available Loading Object On The Fly In the past, there were similar  pattern s to load kinds of Object Components, helpers and tasks could not be loaded  dynamically Now Collection pattern is gathered at ObjectCollection
Decoupling & Delegeting Common API for Collections Loading Object On The Fly ObjectCollection load() attached() trigger() other methods Compatible methods like attach() is also available
Decoupling & Delegeting In Your  Controller $this->Components-> load ('Cookie', array('name' => 'MyCookie')) In Your  Component $this->Auth = $this-> _Collection -> load ('Auth'); In You  View $this->Time = $this-> loadHelper ('Time'); // convenient alias $this->Time = $this-> Helpers -> load ('Time');  In your  Model $this->Behaviors-> load ('Containable'); $this->Behaviors->attach('Containable'); // compatible Loading Object On The Fly
Decoupling & Delegeting Number of  classe s deletege Others Session Handler is now object Configure Reader is available You can load configurations  as  format ed you prefer , like  YAML ,  XML ,  JSON Error Handler and Exception Renderer cakeError () was used for simulation of Exception You can specify what handler is used in core config Custom Object  allows you to develop advanced and freely
Various Problems Resolved
Various Problems Resolved CSRF Protection enhancements Securty Component It was coupled with CSRF protection and form tampering safe-guards Disabling CSRF protection meant disabling form tampering safe-guards  also It prevented generating  dynamic form These are now standalone
Various Problems Resolved Multi-time token is available Securty Component There was only one-time token Sometimes it was not useful Now Security Component can be used practically
Various Problems Resolved Pagination supports GET method Pagination Only parsing query string was supported Generating query string was not supported Now GET method pagination is  fully supported
Various Problems Resolved New Paginator Options Pagination $maxLimit Prevent $limit being  too high value $paramType 'querystring' can be used for GET method ' convertKeys ' for PaginatorHelper::options() Allows other parameters to be included
Various Problems Resolved Behavior can have pagination methods Pagination There was no  way  to make sure what  method is available through Behaviors  on your model Model:: hasMethod () is implemented Mostly same to model methods paginate() paginateCount()
Various Problems Resolved Array can be used as a  named arguments More Flexible Routes Router could not handle array as  named arguments Router::url(array('named' => array())); => named: Array /named[hoge][piyo]:fuga => array('named [hoge][piyo] ' => 'fuga') Now deep array can be used
Various Problems Resolved Full url can be generated More Flexible Routes 1. 3 's custom routes handle only  relative  url function match($url) { return '/users/login'; } 2.x's custom routes can handle  absolute  url function match($url) { return ' https :// auth. example.com/users/login'; }
Various Problems Resolved Lazy Loading in sundry of places Lazy Loading Loading model  costs too expensive LazyModel Core supports lazy loading now Components Helpers Tasks Associated Models Loading controller's component is  not  lazy
Conclusion There are many and many  other  changes PHPUnit DataSource enahancements Nesting Transaction Postgress support improved Standa r dization  for directory structure Static Session ...  And so Core team works hard to make compatible ways Why do you not use 2.0?

En story of cakephp2.0

  • 1.
    Story of CakePHP2.0 2011.1.17 The New Year CakePHP Study in Tokyo
  • 2.
    About Me Name : Shimizu Hiroki( hiromi2424 ) Job : Web Developer(Freelance) L ibraries : github ( Transition , ModularAuth ) W ork : Translation H obby : S inging, Beer!!!
  • 3.
  • 4.
    CakePHP 2.0 haslarge number of enhancements It is no longer same thing compared with 1.x But there are many compatible stuff Most of libraries and applications also can be migrated easily Introduction
  • 5.
    Summary Decoupling &Delegeting Request & Response Auth Loading Object On The Fly Others Various Problems Resolved Security Component Pagination More Flexible Routes Lazy Loading Conclusion
  • 6.
  • 7.
    Decoupling & DelegetingCurrent Requst handling Request & Response Lose Consistency Hard to Test Ugly Workaround Impossible to Inherit
  • 8.
    Decoupling & DelegetingRequst handling in CakePHP 2.0 Request & Response Same Object Common API Parse Request Convenient Method
  • 9.
    Decoupling & DelegetingIn Your Controller or so $this-> request ->here $this->params['prefix'] // also accesible but deprecated $this-> request -> data (' User.name '); // returns name $this->request->data('User.ip_address', $this-> request -> clientIp () ); Request & Response
  • 10.
    Decoupling & DelegetingResponse Handling in CakePHP 2.0 Request & Response All of handling HTTP response would be done through Response object Helps Media Rendering Download HTTP Systems
  • 11.
    Decoupling & DelegetingAuth's Responsibility was too heavy Auth Validating Post Login Login/Logout Handling Loading Current User Various Autorization Pattern DarkAuth OpenID and OAuth
  • 12.
    Decoupling & DelegetingAuth will be separated Auth Authentication and Authorization Basic , Digest Authentication is already available Core Team giving a try to support OpenID
  • 13.
    Decoupling & DelegetingObjectCollection is available Loading Object On The Fly In the past, there were similar pattern s to load kinds of Object Components, helpers and tasks could not be loaded dynamically Now Collection pattern is gathered at ObjectCollection
  • 14.
    Decoupling & DelegetingCommon API for Collections Loading Object On The Fly ObjectCollection load() attached() trigger() other methods Compatible methods like attach() is also available
  • 15.
    Decoupling & DelegetingIn Your Controller $this->Components-> load ('Cookie', array('name' => 'MyCookie')) In Your Component $this->Auth = $this-> _Collection -> load ('Auth'); In You View $this->Time = $this-> loadHelper ('Time'); // convenient alias $this->Time = $this-> Helpers -> load ('Time'); In your Model $this->Behaviors-> load ('Containable'); $this->Behaviors->attach('Containable'); // compatible Loading Object On The Fly
  • 16.
    Decoupling & DelegetingNumber of classe s deletege Others Session Handler is now object Configure Reader is available You can load configurations as format ed you prefer , like YAML , XML , JSON Error Handler and Exception Renderer cakeError () was used for simulation of Exception You can specify what handler is used in core config Custom Object allows you to develop advanced and freely
  • 17.
  • 18.
    Various Problems ResolvedCSRF Protection enhancements Securty Component It was coupled with CSRF protection and form tampering safe-guards Disabling CSRF protection meant disabling form tampering safe-guards also It prevented generating dynamic form These are now standalone
  • 19.
    Various Problems ResolvedMulti-time token is available Securty Component There was only one-time token Sometimes it was not useful Now Security Component can be used practically
  • 20.
    Various Problems ResolvedPagination supports GET method Pagination Only parsing query string was supported Generating query string was not supported Now GET method pagination is fully supported
  • 21.
    Various Problems ResolvedNew Paginator Options Pagination $maxLimit Prevent $limit being too high value $paramType 'querystring' can be used for GET method ' convertKeys ' for PaginatorHelper::options() Allows other parameters to be included
  • 22.
    Various Problems ResolvedBehavior can have pagination methods Pagination There was no way to make sure what method is available through Behaviors on your model Model:: hasMethod () is implemented Mostly same to model methods paginate() paginateCount()
  • 23.
    Various Problems ResolvedArray can be used as a named arguments More Flexible Routes Router could not handle array as named arguments Router::url(array('named' => array())); => named: Array /named[hoge][piyo]:fuga => array('named [hoge][piyo] ' => 'fuga') Now deep array can be used
  • 24.
    Various Problems ResolvedFull url can be generated More Flexible Routes 1. 3 's custom routes handle only relative url function match($url) { return '/users/login'; } 2.x's custom routes can handle absolute url function match($url) { return ' https :// auth. example.com/users/login'; }
  • 25.
    Various Problems ResolvedLazy Loading in sundry of places Lazy Loading Loading model costs too expensive LazyModel Core supports lazy loading now Components Helpers Tasks Associated Models Loading controller's component is not lazy
  • 26.
    Conclusion There aremany and many other changes PHPUnit DataSource enahancements Nesting Transaction Postgress support improved Standa r dization for directory structure Static Session ... And so Core team works hard to make compatible ways Why do you not use 2.0?