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

PHP5.5、いつやるか?今でしょ!

Keisuke SATO
September 14, 2013

 PHP5.5、いつやるか?今でしょ!

オープンソースカンファレンス2013 Hokkaido
https://www.ospn.jp/osc2013-do/modules/eguide/event.php?eid=29

w/ Sapporo.php

Keisuke SATO

September 14, 2013
Tweet

More Decks by Keisuke SATO

Other Decks in Programming

Transcript

  1. Sapporo.php
    PHP5.5
    ͍ͭ΍Δ͔ʁ
    ࠓͰ͠ΐʂ
    ΦʔϓϯιʔεΧϯϑΝϨϯε2013 ๺ւಓ
    ࠤ౻ Ղ༞ ( Sapporo.php )

    View full-size slide

  2. ͋ͨΒ͍͠1)1ͷ৘ใʹৄ͍͠ɻ
    ࠤ౻Ղ༞ઌੜʢҰൠࣾஂ๏ਓ-0$"-ʣ

    View full-size slide

  3. ͓Θͼ
    ࠷ॳ͸ʮPHP5.5 Updateʯ͍ͬͯ͏λΠτϧͰ
    ΍Δ༧ఆͩͬͨΜͰ͚͢Ͳɺʮ΋͏গ͠ώΩ͕
    ͋Δ΄͏͕͍͍ʯͱݴΘΕ·ͯ͠ɺ͍΍͍΍
    PHP5.5 ͷ࿩ʹʮͻ͖ʯͬͯݴΘΕ·ͯ͠΋...
    Έ͍ͨͳײ͡ͰͱΓ͋͑ͣྲྀߦʢ஗Εʣʹͷͬ
    ͯΈͨͱ͜ΖͰݩωλͦΕ΄Ͳৄ͘͠ͳ͍ͷͰ
    ͍ͭ΋Ͳ͓Γਐߦ͠·(ུ

    View full-size slide

  4. ͓Θͼ
    ͪΐͬͱඓ੠ + ࡢ೔༡ͼա͗Ͱ੠͕͓͔͍͠Ͱ
    ͢ɻฉ͖औΓʹ͍࣌͘͸ԕྀແ͘ฉ͖ฦͯ͘͠
    ͍ͩ͞ɻ͝ΊΜͳ͍͞ɻ΄Μͱɺ͝ΊΜͳ͞
    ͍ɻ

    View full-size slide

  5. ࠤ౻Ղ༞
    ๺ւಓ۴࿏ொग़਎ɺ౦ژ౎ࡏॅ
    ೥݄೔ੜ
    !SJBG
    GCNFTBUPLFJTVLF
    Ұൠࣾஂ๏ਓ-0$"-
    ೔ຊ1)1Ϣʔβʔձ

    View full-size slide

  6. PHP ͱ΅͘
    •ߴߍͷࠒ͔Β͞Θ͍ͬͯΔͷͰͳʹ͛
    ʹ 10 ೥Ҏ্...
    •Openpear ͱ͔ͭ͘Γ·ͨ͠
    •Xoops, Ethna, rhaco, Symfony, ...

    View full-size slide

  7. ͋Εɻ͍ͪ͹Μͷཪ൪૊ͳͷͰ͸ʁ

    View full-size slide

  8. ͪͳΈʹࠓ౦ژͰ͸
    • MySQL Admin͕ݟͨDevsͷৗࣝɺDBA͸ඇৗࣝ
    • 15෼Ͱग़དྷΔPHPͱJavaScript MVCϑϨʔϜϫʔΫ
    Ͱ࡞ΔϓϩτλΠϓ
    • PHP 5.5ωʔςΟϒΩϟογϡͷ࿩
    • ϑϩϯτΤϯυ੍࡞޲͚ϏϧυπʔϧGruntΛPHP
    όοΫΤϯυ։ൃͰར༻͢Δ
    • PHP։ൃऀͷͨΊͷΫϥ΢υ؀ڥ -ೖ໳ฤ-

    View full-size slide

  9. Agenda
    •PHP ͷΞοϓσʔτ৘ใ
    •Composer / Packagist
    •PSR, php-fig
    ٧ΊࠐΈ͗ͯ͢આ໌͚ͩʹͳͬͯ͠·͍ͦ͏Ͱ͢
    ୀ۶͔΋͠Εͳ͍Ͱ͕͢ɺ͝ΊΜͳ͍͞ɻ

    View full-size slide

  10. ͬͦ͘͞Ͱ͕͢

    View full-size slide

  11. ͋ͳ͕͓ͨ࢖͍ͷ1)1ͷόʔδϣϯ͸ʁ
    php -v

    View full-size slide

  12. 4.*
    5.0.*
    5.1.*
    5.2.*

    View full-size slide

  13. ͢ͰʹηΩϡϦςΟαϙʔτ΋
    ऴ͍ྃͯ͠·͢ɻ
    ࠓ͙͢ʹΞοϓσʔτ͠·͠ΐ͏ɻ
    ͍ͭ΍Δ͔ʁ
    ΋͏͓ͤʔΑʂ

    View full-size slide

  14. ࣮͸ php5.3 ΋དྷ೥6݄Ͱαϙʔτऴྃ͠·͢
    7݄ʹϦϦʔε͞ΕͨPHP 5.3.27 ͕ 5.3 ܥ࠷ޙ
    ͷ௨ৗΞοϓσʔτͱͳΓɺαϙʔτऴྃ·
    ͰηΩϡϦςΟରԠ͔͠ߦΘΕ·ͤΜɻ

    View full-size slide

  15. ͭ·Γɺphp5.5 ΁ͷΞοϓσʔ
    τΛߟ͑ΔλΠϛϯά͸·͞ʹ

    View full-size slide

  16. ͭ·Γɺphp5.5 ΁ͷΞοϓσʔ
    τΛߟ͑ΔλΠϛϯά͸·͞ʹ

    View full-size slide

  17. ͍΍͍΍ɺͦ͏͸ݴͬͯ΋ݱঢ়ಈ͍ͯΔ͠Ͷ͐...ʁ
    ͱࢥͬͨ
    ͦ͜ͷ͋ͳͨʂ

    View full-size slide

  18. ڈ೥
    • CGI ϞʔυͰಈ࡞͢Δ PHP ʹίϚϯυϥΠϯ
    Φϓγϣϯ͕ΫΤϦετϦϯάͰࢦఆͰ͖ͯ
    ͠·͏੬ऑੑ͕
    • .../hoge.php?-s
    • ιʔείʔυ͕γϯλοΫεϋΠϥΠτ͞Ε
    ͯݟ͑ͪΌ͍ͬͯͨ
    • ͪͳΈʹ Facebook ʹ -s ͚ͭͯΞΫηε͢Δͱٻਓ৘ใͷ URL ͕࢓
    ࠐ·Εͨ php ίʔυΛදࣔͯ͠·ͨ͠ɻ

    View full-size slide

  19. ͦͷ΄͔ʹ΋
    wDSZQUͷόά

    wSBTNVT
    w)551ϔομΠϯδΣΫγϣϯ Ҏ
    લͷIFBEFSؔ਺

    wIBTIEPT ·͋͜Ε͸ઃఆͷ໰୊

    wͳͲͳͲ

    View full-size slide

  20. PHP ͕໰୊ʹͳΔέʔεɺ
    ͦΕͳΓʹ͋Γ·͢ɻ

    View full-size slide

  21. ࠷௿Ͱ΋
    • 5.3.2 ͱ͔ɺத్൒୺ͳόʔδϣϯΛ࢖Θͣ
    ʹɺ࠷৽όʔδϣϯ (5.3.27) ͱ͔ɺϚΠφʔΞ
    οϓσʔτ͸͢΂ͯద༻͓ͯ͘͠
    • Ͳ͏ͯ͠΋ݹ͍όʔδϣϯ͕ඞཁͳͱ͖͸ɺ
    ͲͷΑ͏ͳ໰୊Λ๊͍͑ͯΔͷ͔೺Ѳ͢Δ
    ʢ໰୊͕ൃੜ͢ΔͳΒमਖ਼͢Δʣ

    View full-size slide

  22. PHP 5.4 ͷ͓͞Β͍

    View full-size slide

  23. PHP 5.3 ͷ͓͞Β͍
    ͦͷ·͑ʹɺ͚ͩ͢͜͠

    View full-size slide

  24. 5.3 ͷ৽ػೳ
    •໊લۭؒ
    •஗Ԇ੩తଋറ
    •goto...
    •ωΠςΟϒΫϩʔδϟʢແ໊ؔ਺ʣ
    •__callStaticɺ__invoke ϚδοΫϝιο
    υͷ௥Ճ

    View full-size slide

  25. 5.3 ͷ৽ػೳ
    •Nowdoc
    •Ϋϥε֎Ͱͷ const Ωʔϫʔυ
    •?: ʢࡾ߲ԋࢉࢠͷ୹ॖʣ
    •੩తϝιουʹಈతΞΫηεʢ$a::$b)
    •ྫ֎ͷωετ

    View full-size slide

  26. ৽ػೳ͚ͩͰ੝Γͩ͘͞Μ

    View full-size slide

  27. 5.3 ͦͷଞʹ΋
    •52 ͷ৽͍ؔ͠਺
    •18 ͷ৽͍͠ύϥϝʔλରԠͷؔ਺
    •18 ͷ৽͍͠ϝιου
    •18 ͷ৽͍͠Ϋϥε

    View full-size slide

  28. PHP 5.4 ͷ͓͞Β͍

    View full-size slide

  29. 5.4 ͷ৽ػೳ
    •τϨΠτ
    •഑ྻͷ୹ॖߏจ
    •= ͕ৗʹ༗ޮʹ
    •foo()[1]
    •(new Foo)->bar()
    •built-in webserver

    View full-size slide

  30. ηʔϑϞʔυͷഇࢭ
    • 5.3 ͔Βඇਪ঑Ͱͨ͠

    View full-size slide

  31. ϚδοΫΫΦʔτͷഇࢭ
    • 5.3 ͔Βඇਪ঑Ͱͨ͠
    • ͪΌΜͱΤεέʔϓ͠·͠ΐ͏Ͷ

    View full-size slide

  32. register_globals ഇࢭ
    • ࠓߋ࢖ͬͯͳ͍ͱ͸͓΋͍·͕͢ɻ
    • register_long_arrays ΋ഇࢭ͞Εͯ·͢ɻ
    • $_HTTP_*_VARS తͳ΍ͭ
    • extract($_REQUEST) ͢ΓΌ͍͍ͬͯ͜ͱͰ͸
    ͳ͍Ͱ͢Αɻ͖ͪͬͱѻ͍·͠ΐ͏Ͷɻ

    View full-size slide

  33. Call-time pass-by-reference ഇࢭ
    • ݺͼग़࣌͠ͷࢀর౉͠
    • foo(&$bar)

    View full-size slide

  34. date.timezone ઃఆඞਢ
    • TZ ؀ڥม਺Λࢀর͠ͳ͘ͳͬͨ
    • date_default_timezone_set()
    • ઃఆ͠ͳ͍ͱ UTC ʹͳͬͯ Warning ͕ൃੜ

    View full-size slide

  35. 5.4 Ͱ͸ɺ·ͱ΋ͳਐԽ͕ɻ

    View full-size slide


  36. • apc ͕ΠϚΠν
    • ฐࣾαʔϏε΋Α͘ apc ͷ͍ͤͰίέ·͢
    • OPcache Λ࢖͏ͱ҆ఆͦ͠͏ͳ༧ײ
    • ςετ؀ڥͰ͸໰୊ͳ͘ಈ͍͍ͯΔ
    • ·ͩ production ʹ͸͍Εͯ·ͤΜ
    • ͋ͱͰ·ͨઆ໌͠·͢Ͷ

    View full-size slide

  37. ͯ͞ɺ5.5 Ͱ͸

    View full-size slide

  38. 5.5 ͷ৽ػೳ

    View full-size slide

  39. δΣωϨʔλͷ௥Ճ
    • yield Ωʔϫʔυ

    View full-size slide

  40. finally Ωʔϫʔυͷ௥Ճ
    • ԿΛ͍·͞Β...
    • try .. catch .. finally

    View full-size slide

  41. password_* ؔ਺
    • ύεϫʔυͷѻ͍Λ؆୯ʹ
    • ݱࡏ͸ bcrypt ͷΈରԠ

    View full-size slide

  42. foreach now support list()

    View full-size slide

  43. empty ͕೚ҙͷࣜʹରԠ
    • ͡Έʹ͏Ε͍͠

    View full-size slide

  44. array, string ͷσϦϑΝϨϯε

    View full-size slide

  45. ::class
    • ClassName::class Ͱ namespace ΛؚΉΫϥε
    ໊ΛऔಘͰ͖ΔΑ͏ʹ

    View full-size slide

  46. OPcache extension
    • Zend Optimizer+ ͷΦϖίʔυΩϟογϡ
    • ΋ͱ΋ͱ༗ྉͰఏڙ͞Εͯͨ΍ͭͰ͢
    • ։ൃ൛Ͱ͸ apc ΑΓ਺% ʙ 20 % ΄Ͳߴ଎
    • apc ͸ 5.5 ޲͚ʹ͸ఏڙ͞Ε͍ͯ·ͤΜ
    • apc_store, apc_fetch ͳͲͷ KVS ػೳ͚ͩ
    Λఏڙ͢Δ apcu extension ͕͋Γ·͢

    View full-size slide

  47. ͦͷଞ
    • foreach ͕ඇεΧϥʔͷΩʔʹରԠ
    • ωΠςΟϒͷ഑ྻ͸εΧϥʔͷΈ
    • Iterator::key() ͕೚ҙͷ஋ΛฦͤΔ
    • Apache 2.4 ϋϯυϥ͕ Windows ʹରԠ
    • GD ͷվྑ

    View full-size slide

  48. มߋ఺ϐοΫΞοϓ

    View full-size slide

  49. Deprecated
    • preg_replace ͷ /e म০ࢠ
    • ͔ΘΓʹ preg_replace_callback Λ
    • ҙ֎ͱϋϚΓͲ͜ΖɻErrorException Ͱɻ
    • ext/mysql extension
    • ͔ΘΓʹ mysqli ͔ pdo_mysql Λ

    View full-size slide

  50. ͦͷଞ
    • Windows XP / 2003 ͷαϙʔτऴྃ
    • pack / unpack ͷԼҐޓ׵ੑͷͳ͍มߋ

    View full-size slide

  51. Composer
    • PHP 5.3.2 ͔Β࢖͑Δύοέʔδ؅ཧπʔϧ
    • Ruby Ͱ͍͏ Bundler, node Ͱ͍͏ npm త
    ͳ΍ͭ
    • composer.json / autoload.php
    • Symfony, Zend Framework, PHPUnit, ...
    • git ͸ඞਢ͔΋ɻ
    • ϩΰ͕͍ͩ͞

    View full-size slide

  52. Packagist
    • Composer ඪ४ϦϙδτϦ
    • ͩΕͰ΋ొ࿥Ͱ͖·͢
    • 15,000 ύοέʔδҎ্ʂ
    • PEAR ͸ 600 ऑ
    • ೦ئͷύοέʔδ਺ʂ

    View full-size slide

  53. PSR
    • ༗໊ϑϨʔϜϫʔΫ࡞ऀͨͪͰߏ੒͞ΕΔ
    php-fig ͕ࡦఆ͍ͯ͠ΔίʔσΟϯάن໿
    • ͦΕͧΕͷϑϨʔϜϫʔΫͰͦΕͧΕͷίʔ
    σΟϯάن໿Λ࡞Βͣʹɺ౷ҰͷίʔσΟϯ
    άن໿ʹ͠·͠ΐ͏ɻͱ͍͏͓͸ͳ͠

    View full-size slide

  54. php-fig members
    "HBWJ
    %BWJE;ÛMLF !E[VFMLF

    "NB[PO8FC4FSWJDFT4%,
    3ZBO1BSNBO !4LZ[ZY

    "QBDIFMPHQIQ
    *WBO)BCVOFL !JIBCVOFL

    "TTFUJDBOE#V[[
    ,SJT8BMMTNJUI !LSJTXBMMTNJUI

    "VSB1SPKFDUBOE4PMBS'SBNFXPSL
    1BVM.+POFT !QNKPOFT

    $BLF1)1
    -BSSZ.BTUFST !1IQ/VU

    $PNQPTFSBOE1BDLBHJTU
    +PSEJ#PHHJBOP !TFMEBFL

    %PDUSJOF
    (VJMIFSNF#MBODP !HVJMIFSNFCMBODP

    %SVQBM
    -BSSZ(BSpFME !$SFMM

    F;1VCMJTI
    "OESF3PNDLF !BOESFSPN

    5:10'MPX
    ,BSTUFO%BNCFLBMOT !LEBNCFLBMOT

    +BDLBMPQF
    -VLBT,BIXF4NJUI !MTNJUI

    +PPNMB
    %PO(JMCFSU !EJMCFSUMJGF

    -BSBWFM
    5BZMPS0UXFMM !UBZMPSPUXFMM

    -JUIJVN
    /BUF"CFMF !OBUFBCFMF

    1&"3
    #SFUU#JFCFS !TBMUZCFBHMF

    QIQ##
    /JMT"EFSNBOO !OBEFSNBO

    QIQ%PDVNFOUPS
    .JLFWBO3JFM !NWSJFM

    11*
    1BVM%SBHPPOJT !ESHPPOJT

    1SPQFM
    8JMMJBN%VSBOE !DPVBD

    1ZSP$.4
    1IJM4UVSHFPO !QIJMTUVSHFPO

    4BCSF%"7
    &WFSU1PU !FWFSUQ

    4VHBS$3.
    +PIO.FSUJD !KNFSUJD

    4ZNGPOZ
    'BCJFO1PUFODJFS !GBCQPU

    5IFDPNNVOJUZBUMBSHF
    $BM&WBOT !$BM&WBOT

    ;FOE'SBNFXPSL
    1ÂESBJD#SBEZ !QBESBJDC

    ;JLVMB
    ,BSNB%PSESBL ![JLVMBESBL

    View full-size slide

  55. PSR
    • PSR-0
    • ϑΝΠϧ໊ͱΫϥε໊ͷن໿
    • PSR-1
    • ίʔσΟϯάن໿
    • PSR-2
    • ίʔσΟϯάελΠϧن໿
    • PSR-3
    • ϩΨʔͷΠϯλϑΣʔεن໿

    View full-size slide

  56. Sapporo.php
    • PHP ๺ւಓ with LOCAL
    • LOCAL PHP෦
    • sapporo-php.net
    • 2 ϲ݄ʹҰ౓͘Β͍ษڧձ౳

    View full-size slide

  57. ຊ೔ͷ·ͱΊ
    • php5.3 Ҏલͷόʔδϣϯ͸΋͏ݹ͍
    • φ΢͍ύοέʔδґଘ؅ཧ͸ Composer
    • ͦͯ͠ Packagist ͰͲΜͲΜެ։
    • ίʔσΟϯάن໿͸ PSR Ͱ
    • ೔ຊޠ༁͸ Infinite loop ͞Μ

    View full-size slide

  58. Any question ?
    • ʮྑ͍࣭໰Ͱ͢Ͷʯ͕ग़Δͱ PHP Matsuri Tγ
    ϟπ͋͛·͢
    • ྑ͍࣭໰͗͢Δͱ๻͕౴͑ΒΕͳ͍Մೳੑ͕
    ͋Γ·͢

    View full-size slide

  59. いつ終わるか?
    今でしょ!
    ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
    Sapporo.php

    View full-size slide