En story of cakephp2.0

1,224 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,224
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

En story of cakephp2.0

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

×