$30 off During Our Annual Pro Sale. View Details »

Lessons and learns from migration CakePHP1.x

Yusuke Ando
September 01, 2012

Lessons and learns from migration CakePHP1.x

CakeFest2012

Yusuke Ando

September 01, 2012
Tweet

More Decks by Yusuke Ando

Other Decks in Technology

Transcript

  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

    View Slide

  2. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)
    ςΩετ

    View Slide

  3. $BLF'FTUYusuke Ando (@yando)

    View Slide

  4. $BLF'FTUYusuke Ando (@yando)
    what’s CandyCane
    the reason of migration
    things to be done
    conclusion
    $BLF'FTUYusuke Ando (@yando)
    Agenda

    View Slide

  5. $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)

    View Slide

  6. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)

    View Slide

  7. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)

    View Slide

  8. $BLF'FTUYusuke Ando (@yando)
    45-seconds install
    $BLF'FTUYusuke Ando (@yando)

    View Slide

  9. $BLF'FTUYusuke Ando (@yando)
    http://www.youtube.com/watch?v=0j2q7xYdiYU
    $BLF'FTUYusuke Ando (@yando)

    View Slide

  10. $BLF'FTUYusuke Ando (@yando)
    plugin web install
    $BLF'FTUYusuke Ando (@yando)

    View Slide

  11. $BLF'FTUYusuke Ando (@yando)
    http://www.youtube.com/watch?v=sTU7DYxnbZg
    $BLF'FTUYusuke Ando (@yando)

    View Slide

  12. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)
    Sign in with Facebook account.

    View Slide

  13. $BLF'FTUYusuke Ando (@yando)
    29 Controller
    63 Model
    219 View
    76 Element
    $BLF'FTUYusuke Ando (@yando)
    Amount of code.
    By ShutterBugChef at Flickr

    View Slide

  14. $BLF'FTUYusuke Ando (@yando)

    View Slide

  15. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)
    Migration
    photo by hyku

    View Slide

  16. $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

    View Slide

  17. $BLF'FTUYusuke Ando (@yando)
    https://github.com/ichikaway/CakePHP-
    PerformanceCheckSample

    View Slide

  18. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)
    Lazy load
    only this class is
    loaded, because it’s
    used in action!

    View Slide

  19. $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’);

    View Slide

  20. $BLF'FTUYusuke Ando (@yando)
    Theme can change any view.
    Classic
    Default
    Kuma

    View Slide

  21. $BLF'FTUYusuke Ando (@yando)
    Email via SMTP

    View Slide

  22. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)
    Event system
    CandyHelper-
    >textilizable()
    CcEmoji
    emoji_convert
    inject filter via Event

    View Slide

  23. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)
    Event system

    View Slide

  24. $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

    View Slide

  25. $BLF'FTUYusuke Ando (@yando)

    View Slide

  26. $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

    View Slide

  27. $BLF'FTUYusuke Ando (@yando)
    •core.php
    •index.php
    •.htaccess
    •copy original file into your app.
    •reconfigure what you need.
    $BLF'FTUYusuke Ando (@yando)
    configs

    View Slide

  28. $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’]

    View Slide

  29. $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”);

    View Slide

  30. $BLF'FTUYusuke Ando (@yando)
    •getMicrotime()
    •e()
    •r()
    •a()
    •aa()
    •up()
    •low()
    •params()
    •ife()
    •uses()
    $BLF'FTUYusuke Ando (@yando)
    no more shortcuts

    View Slide

  31. $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 {
    }

    View Slide

  32. $BLF'FTUYusuke Ando (@yando)
    •standard View now supports theme.
    •use standard view class.
    $BLF'FTUYusuke Ando (@yando)
    ThemeView
    // no code required
    $viewClass = ‘Theme’;

    View Slide

  33. $BLF'FTUYusuke Ando (@yando)
    •AjaxHelper is removed.
    •use JSHelper
    •some method are incompatible.
    $BLF'FTUYusuke Ando (@yando)
    AjaxHelper

    View Slide

  34. $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.

    View Slide

  35. $BLF'FTUYusuke Ando (@yando)
    $BLF'FTUYusuke Ando (@yando)
    Join us.
    https://github.com/yandod/candycane

    View Slide