Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Lessons and learns from migration CakePHP1.x

Yusuke Ando
September 01, 2012

Lessons and learns from migration CakePHP1.x


Yusuke Ando

September 01, 2012

More Decks by Yusuke Ando

Other Decks in Technology


  1. $BLF'FTUYusuke Ando (@yando) CandyCane $BLF'FTUYusuke Ando (@yando) Lessons and learns

    from migration to CakePHP2 from CakePHP1.x https://github.com/yandod/candycane
  2. $BLF'FTUYusuke Ando (@yando) what’s CandyCane the reason of migration things

    to be done conclusion $BLF'FTUYusuke Ando (@yando) Agenda
  3. $BLF'FTUYusuke Ando (@yando) CakePHP port of Redmine started since April

    2009 v0.9-RC 45-seconds install i18n ready easy of develop plugin Facebook connectivity 27+ contributors CandyCane $BLF'FTUYusuke Ando (@yando)
  4. $BLF'FTUYusuke Ando (@yando) 29 Controller 63 Model 219 View 76

    Element $BLF'FTUYusuke Ando (@yando) Amount of code. By ShutterBugChef at Flickr
  5. $BLF'FTUYusuke Ando (@yando) •performance (40%+) drop PHP4 support, lazy load

    •more features PHPUnit, JsonView, Theme, Email •more flexibility Event handling, I18n, plugin $BLF'FTUYusuke Ando (@yando) CakePHP2 gives you
  6. $BLF'FTUYusuke Ando (@yando) •Theme can swap specific view file. •Also

    can swap assets file. •use default file if file isn’t in theme. •only need to create particular file. $BLF'FTUYusuke Ando (@yando) Theme app/View/Themed/fest/Home/index.ctp or app/View/Home/index.ctp $this->theme = ‘fest’; $this->render(‘Home/index’);
  7. $BLF'FTUYusuke Ando (@yando) •rename files and directories •core.php / index.php

    / .htaccess •CakeRequest •cakeError •remove deprecated functions •Component •ThemeView •AjaxHelper $BLF'FTUYusuke Ando (@yando) things to be done
  8. $BLF'FTUYusuke Ando (@yando) •Upgrade Shell take care almost all. •File

    name match with class name. app/Controller/FooController.php •consider sub directories in Elements: app/View/Elements/subdir/foo.ctp •make sure your dev environment. OS X (later Lion) and Win are case INSENSITIVE $BLF'FTUYusuke Ando (@yando) rename
  9. $BLF'FTUYusuke Ando (@yando) •core.php •index.php •.htaccess •copy original file into

    your app. •reconfigure what you need. $BLF'FTUYusuke Ando (@yando) configs
  10. $BLF'FTUYusuke Ando (@yando) •must handle request with new way. $BLF'FTUYusuke

    Ando (@yando) CakeRequest $this->request->data $this->request->query $this->request->pass $this->request->named $this->data $this->params[‘url’] $this->params[‘pass’] $this->params[‘named’]
  11. $BLF'FTUYusuke Ando (@yando) •throw CakeException for Error. •grep cakeError() •give

    status code as parameter. $BLF'FTUYusuke Ando (@yando) CakeError throw new CakeException(“User not found”,404); $this->cakeError(“error404”);
  12. $BLF'FTUYusuke Ando (@yando) •getMicrotime() •e() •r() •a() •aa() •up() •low()

    •params() •ife() •uses() $BLF'FTUYusuke Ando (@yando) no more shortcuts
  13. $BLF'FTUYusuke Ando (@yando) •now Component has super class. •fit constructor

    as super class. $BLF'FTUYusuke Ando (@yando) Component class FooComponent { } class FooComponent extends Component { }
  14. $BLF'FTUYusuke Ando (@yando) •standard View now supports theme. •use standard

    view class. $BLF'FTUYusuke Ando (@yando) ThemeView // no code required $viewClass = ‘Theme’;
  15. $BLF'FTUYusuke Ando (@yando) •AjaxHelper is removed. •use JSHelper •some method

    are incompatible. $BLF'FTUYusuke Ando (@yando) AjaxHelper
  16. $BLF'FTUYusuke Ando (@yando) Migration to 2.x from 1.x is PAIN.

    2.x comes with great feature. Profits over PAIN. $BLF'FTUYusuke Ando (@yando) Lessons.