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

    ΋΋͍ΖΫϩʔόʔZ Sotaro Karasawa ฑ୔૱ଠ࿠ ϩϦϙ͓͡͞Μ
  2. 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
  3. PHP 5.4 - Build in server - Array short syntax

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

    Array Dereferencing $basename = pathinfo(__FILE__)['basename'];
  5. ͍·͙͢࢖͑Δ 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/
  6. ιʔε͔ΒೖΕΔ 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/
  7. 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
  8. 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
  9. Ҡߦʹ͋ͨͬͯ஫ҙ͢΂͖͜ͱ ֦ுػೳܥ͸஫ҙ͕ඞཁ͋Δఔ౓ɻ ݹ͍ίʔυΛ࣋ͬͯΔਓ: - magic quotes ܥؔ਺ - register globals

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

    = 2; add(&$b); // => Fatal error: Call-time pass-by- reference has been removed
  11. !?

  12. ͳͥ 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
  13. ͳͥ PHP 5.4 Λࠓ͙͢࢖͓͏ͱ͢΂͖͔ - ٕज़ऀͷཆ੒ - ૣ͔͘ΒΩϟονΞοϓ͢Δ͜ͱͰɺTraits ͳͲΛ ༻͍ͨϓϩάϥϛϯάͷͰ͖Δਓɾ؀ڥΛͭ͘Δ

    - ϓϥΫςΟεΛ஝ੵͤ͞Δ - Traits Λ࢖ͬͨϥΠϒϥϦ͸࣍ʑͱग़ͯ͘Δ͸ͣ - ݹ͍όʔδϣϯͰϝϯς͠ଓ͚Δίετ - ࠓ͸େม͚ͩͲ ͞Βʹݴ͑͹