1 / 26

Story of CakePHP 2.0

2011.1.17 The New Year CakePHP Study in Tokyo. Story of CakePHP 2.0. About Me. Introduction. 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

osman
Télécharger la présentation

Story of CakePHP 2.0

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2011.1.17 The New Year CakePHP Study in Tokyo Story of CakePHP 2.0

  2. AboutMe

  3. Introduction

  4. 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

  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. Decoupling & Delegeting

  7. Decoupling & Delegeting Request & Response Current Requst handling • Lose Consistency • Hard to Test • Ugly Workaround • Impossible to Inherit

  8. Decoupling & Delegeting Request & Response Requst handling in CakePHP 2.0 • Same Object • Common API • Parse Request • Convenient Method

  9. Decoupling & Delegeting Request & Response 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() );

  10. Decoupling & Delegeting Request & Response Response Handling in CakePHP 2.0 • All of handling HTTP response would be done through Response object • Helps • Media Rendering • Download • HTTP Systems

  11. Decoupling & Delegeting Auth Auth's Responsibility was too heavy • Validating Post Login • Login/Logout Handling • Loading Current User • Various Autorization Pattern • DarkAuth • OpenID and OAuth

  12. Decoupling & Delegeting Auth Auth will be separated • Authentication and Authorization • Basic, Digest Authentication isalready available • Core Team giving a try to support OpenID

  13. Decoupling & Delegeting Loading Object On The Fly ObjectCollection is available • In the past, there were similar patterns toload kinds of Object • Components, helpers and tasks could not beloaded dynamically • Now Collection pattern is gathered atObjectCollection

  14. Decoupling & Delegeting Loading Object On The Fly Common API for Collections • ObjectCollection • load() • attached() • trigger() • other methods • Compatible methods like attach() is alsoavailable

  15. Decoupling & Delegeting Loading Object On The Fly 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

  16. Decoupling & Delegeting Others Number of classes deletege • Session Handler is now object • Configure Reader is available • You can load configurations as formated 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. Various Problems Resolved

  18. Various Problems Resolved Securty Component CSRF Protection enhancements • It was coupled with CSRF protection andform tampering safe-guards • Disabling CSRF protection meant disablingform tampering safe-guardsalso • It prevented generating dynamic form • These are now standalone

  19. Various Problems Resolved Securty Component Multi-time token is available • There was only one-time token • Sometimes it was not useful • Now Security Component can beused practically

  20. Various Problems Resolved Pagination Pagination supports GET method • Only parsing query string was supported • Generating query string was not supported • Now GET method pagination is fully supported

  21. Various Problems Resolved Pagination New Paginator Options • $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 Resolved Pagination Behavior can have pagination methods • 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 Resolved More Flexible Routes Array can be used as a named arguments • 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 Resolved More Flexible Routes Full url can be generated • 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 Resolved Lazy Loading Lazy Loading in sundry of places • 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 are many and many other changes • PHPUnit • DataSource enahancements • Nesting Transaction • Postgress support improved • Standardization for directory structure • Static Session • ... And so • Core team works hard to make compatible ways • Why do you not use 2.0?

More Related