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

入門 PHP 5.4 / Introduction of PHP 5.4

入門 PHP 5.4 / Introduction of PHP 5.4

PHP勉強会@東京 #58 発表資料です。

http://d.hatena.ne.jp/sotarok/20120328/1332864411

Sotaro Karasawa

March 27, 2012
Tweet

More Decks by Sotaro Karasawa

Other Decks in Technology

Transcript

  1. ೖ໳ PHP 5.4 Introduction of PHP 5.4 @sotarok http://git.io/sotarok PHPษڧձ@౦ژ

    #58
  2. PHP 5.4 ! ΋͏࢖ͬͯ·͔͢

  3. PHP 5.4 ࠓ೔ͷ࿩

  4. WEB+DB PRESS Vol.65 http://www.amazon.co.jp/dp/477414830X/

  5. WEB+DB PRESS Vol.59 http://www.amazon.co.jp/dp/4774143898/ ͳΜͱ ·ͪΘͼͨʂ

  6. ػೳͱ͔঺հ ͪΐͬͱ࢖ͬͯΈΔ ֤ϥΠϒϥϦͷରԠঢ়گ  PHP 5.4 Ҡߦ͍ͭ͠·͠ΐ͏͔ ࠓ೔ͷ࿩

  7. Crocos, Inc. Ethna git-daily ύʔϑΣΫτPHP ࣗݾ঺հ Red Bull ϓϦϯ Perfume

    ΋΋͍ΖΫϩʔόʔZ Sotaro Karasawa ฑ୔૱ଠ࿠ ϩϦϙ͓͡͞Μ
  8. PHP 5.4 ʹ͍ͭͯ

  9. PHP 5.4 ৽ػೳʹ͍ͭͯ ·ͣಡΉ΂͖ࢿྉ PHP 5.4: The New Bits http://speakerdeck.com/u/dshafik/p/php-54-the-new-bits

    Begin your love affair with traits http://slidesha.re/ssKtnP PHP 5.3.x ͔Β PHP 5.4.x ΁ͷҠߦ http://www.php.net/manual/ja/migration54.php
  10. PHP 5.4 - Build in server - Array short syntax

    - Array Dereferencing - Traits - Binary Notation - Upload Progress - Delete Deprecation (safe mode, magic quotes etc.) - ͋ͱ͍Ζ͍Ζ (͒
  11. Array Short Syntax $array = [1, 2, 'miyazaki' => 'aoi',];

    Array Dereferencing $basename = pathinfo(__FILE__)['basename'];
  12. Class member access on instantiation echo (new \DateTime())->format('Y-m-d');

  13. SessionHandler http://www.php.net/manual/ja/class.sessionhandler.php http://www.php.net/manual/ja/class.sessionhandlerinterface.php class DumpSessionHandler extends SessionHandler { public function

    read($id) { $data = parent::read($id); var_dump($data); return $data; } }
  14. Traits http://jp.php.net/manual/ja/language.oop5.traits.php trait FileWriter { public function write($content) { //

    ... } } class FileLogger implements Logger { use FileWriter; }
  15. ͪΐͬͱ͍ͬͯ͡ΈΔ

  16. ͍·͙͢࢖͑Δ PHP 5.4 CentOS → Debian ʹೖΕସ͑Δ ·͊ɺremi-test Ͱ࢖͑Δ͸ͣ Debian

    → dotdeb http://www.dotdeb.org/2012/03/13/packages-of-php-5-4-0-have-been- updated/ Crocos → http://php.marvel.strk.jp/deb/
  17. ιʔε͔ΒೖΕΔ PHP 5.4 ࠷ۙྲྀߦΓͷ php-build + phpenv Built-in-server ͕͋Δ͓ӄͰԸܙ΋ഒ૿ ࢀߟจݙ:

    phpenv Ͱෳ਺ͷ PHP ؀ڥΛ؅ཧ͢Δ - Born Too Late http://blog.yuyat.jp/archives/1446 phpenv+php-build+pyrusͰͷෳ਺όʔδϣϯPHP؅ཧͳͲ http://blog.dataich.com/2012/01/11/multiple-versions-php-phpenv- phpbuild-pyrus/
  18. ໘౗͔ͩΒαʔό1୆आΓΔ ͘͞ΒVPS http://vps.sakura.ad.jp/ 3/29 ϦχϡʔΞϧ͔ͩΒগ͠଴ͭͱྑ͍͔΋ ϋΠεϖοΫʹʂ҆͘ʂ

  19. ࣮ࡍʹ͍ͬͯ͡ΈΔ ...

  20. ֤ϥΠϒϥϦͷରԠঢ়گʹ͍ͭͯ ͋·ΓࢀߟʹͳΒͳ͍৘ใ

  21. Symfony2, Doctrine2 ͏͍ͯ͝·͢

  22. APC × 3.1.9 ࢖͏ͳΒ SVN ͷ΍ͭ $ svn co https://svn.php.net/repository/pecl/apc/

    trunk ./apc-src $ cd apc-src $ phpize $ ./configure && make && sudo make install
  23. Xdebug × 2.1.4 2.2.0 RC2 or GitHub $ git clone

    https://github.com/derickr/xdebug.git $ cd xdebug $ phpize $ ./configure && make && sudo make install
  24. Ethna ? 2.6.0 Ͱ PHP 5.3 ରԠͯ͠·͕͢φχΧ

  25. ͦͷଞ ಈ͘ͱࢥ͍·͢ PHP 5.3 Ͱਅ໘໨ʹ΍ͬͯͨϠπͳΒಈ͘

  26. PHP 5.4 Ҡߦ͍ͭ͠·͠ΐ͏͔

  27. Ҡߦʹ͋ͨͬͯ஫ҙ͢΂͖͜ͱ ΄ͱΜͲͳ͍ʂ ʮPHP 5.3 ·ͰͷରԠΛ͔ͬ͠Γ΍͖͍ͬͯͯΕ͹ʯ(2ճ໨) ·ͩ Production ʹ͸ೖΕͯͳ͍͚ͲɺStaging Ͱ͸ฐ ࣾΞϓϦ

    (PHP 5.3 + Symfony2) ͸ݩؾʹಈ͍͍ͯΔ
  28. Ҡߦʹ͋ͨͬͯ஫ҙ͢΂͖͜ͱ ֦ுػೳܥ͸஫ҙ͕ඞཁ͋Δఔ౓ɻ ݹ͍ίʔυΛ࣋ͬͯΔਓ: - magic quotes ܥؔ਺ - register globals

    - Call-time pass-by-reference ͍΍͜ͷ΁Μͷ࿩ͰυΩυΩ͢Δਓ͸ PHP 5.4 Ҏલʹ 5.3 ʹ΋͋͛ΒΕͳ͍ͷͰ͸આ
  29. Call-time pass-by-reference function add(&$a) { $a += 1; } $b

    = 2; add(&$b); // => Fatal error: Call-time pass-by- reference has been removed
  30. ͋ͳ͕͍ͨͭ PHP 5.4 Λ࢖͓͏ͱ͢΂͖͔

  31. !?

  32. None
  33. ͳͥ PHP 5.4 Λࠓ͙͢࢖͓͏ͱ͢΂͖͔ - ϓϩάϥϛϯάɾ࠶ར༻ͷଅਐ: Traits - ଎͍ɾলϝϞϦ -

    http://travis-ci.org/#!/sotarok/git-daily/builds/800708h PHP 5.3: 13.00Mb, PHPUnit 4s, Behat 0.867s PHP 5.4: 7.75Mb, PHPUnit 3s, Behat 0.637s
  34. ͳͥ PHP 5.4 Λࠓ͙͢࢖͓͏ͱ͢΂͖͔ - ʮͦ͏͠ͳ͚Ε͹ͳΒͳ͘ͳ͔ͬͯΒʯͰ͸஗͍ - ͕࣌ؒܦͯ͹ཱͭ΄ͲҠߦ͸େม - όʔδϣϯ͕ؒ޿͕Δ΄ͲҠߦ͸େม

    ྫ: ʮSymfony ͕PHP 5.3 ࠓ౓͔Βαϙʔτ͠ͳ͘ͳΔ Β͍͠ΑʂͲ͏͠Α͏Կ΋४උ͍ͯ͠ͳ͍ʂʯ
  35. ͳͥ PHP 5.4 Λࠓ͙͢࢖͓͏ͱ͢΂͖͔ - ٕज़ऀͷཆ੒ - ૣ͔͘ΒΩϟονΞοϓ͢Δ͜ͱͰɺTraits ͳͲΛ ༻͍ͨϓϩάϥϛϯάͷͰ͖Δਓɾ؀ڥΛͭ͘Δ

    - ϓϥΫςΟεΛ஝ੵͤ͞Δ - Traits Λ࢖ͬͨϥΠϒϥϦ͸࣍ʑͱग़ͯ͘Δ͸ͣ - ݹ͍όʔδϣϯͰϝϯς͠ଓ͚Δίετ - ࠓ͸େม͚ͩͲ ͞Βʹݴ͑͹
  36. PHP 5.3 ͕͍ͭ·Ͱαϙʔτ͞ΕΔ͔ 3/3 ʹͦ͏͍ͬͨٞ࿦͸͕͍͋ͬͯΔ ·ͩ݁࿦͕ग़ΔΑ͏ͳஈ֊Ͱ͸ͳ͍ https://wiki.php.net/rfc/php53eol http://news.php.net/php.internals/58469

  37. ·ͱΊ

  38. ·ͱΊ PHP 5.4 Λ࢖͍·͠ΐ͏