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

PHP のドキュメントを読んで PHP のことをもっと知ろう

PHP のドキュメントを読んで PHP のことをもっと知ろう

at PHP BLT #3

Katsuhiro Ogawa

March 01, 2016
Tweet

More Decks by Katsuhiro Ogawa

Other Decks in Technology

Transcript

  1. 1)1ͷυΩϡϝϯτΛಡΜͰ
    1)1ͷ͜ͱΛ΋ͬͱ஌Ζ͏
    খ઒༤େ!pWFTUS
    1
    PHP BLT #3

    View full-size slide

  2. খ઒༤େ (͓͕Θ͔ͭͻΖ)
    @fivestr
    Racing Driver (Amateur)
    Author of "Perfect PHP"
    CTO at Ancar Inc.
    2

    View full-size slide

  3. Έͳ͞Μ1)1ͷ࠷৽ಈ޲͸νΣοΫͯ͠·͔͢ʁ
    w 1)1ͰԿ͕৽͘͠ͳ͔ͬͨ
    w ࠓޙͲͷΑ͏ͳػೳ͕௥Ճ͞ΕΔ͔
    3

    View full-size slide

  4. 1)1
    w εΧϥʔλΠϓώϯτ
    w ϦλʔϯλΠϓώϯτ
    w ԋࢉࢠ /VMM߹ମԋࢉࢠ

    w ԋࢉࢠ εϖʔεγοϓԋࢉࢠ

    w ແ໊Ϋϥε
    4

    View full-size slide

  5. 1)1&SSPS
    w 5ISPXBCMF
    w &SSPS
    w &YDFQUJPO
    w ͪͳΈʹ#BTF&YDFQUJPOͰ͸ͳ͘ͳΓ·ͨ͠
    5

    View full-size slide

  6. use Entity\{Article, Author, Comment};
    6

    View full-size slide

  7. ҠߦυΩϡϝϯτΛಡΈ·͠ΐ͏
    w <1)1Y͔Β1)1Y΁ͷҠߦ>

    IUUQQIQOFUNBOVBMKBNJHSBUJPOQIQ

    w ֤ϝδϟʔϚΠφʔόʔδϣϯ͝ͱʹ

    ҠߦυΩϡϝϯτ͕͋Γ·͢
    w
    w υΩϡϝϯτͷτοϓ͔ΒḷΕ·͢
    7

    View full-size slide

  8. ҠߦυΩϡϝϯτ͍͢͝
    w جຊతʹ͢΂ͯͷมߋ͕·ͱΊΒΕ͍ͯ·͢
    w ͔͠΋͍͍ͩͨ຋༁͞Ε͍ͯ·͢
    w NUBLBHJ͞Μຊ౰ʹ͋Γ͕ͱ͏

    8

    View full-size slide

  9. ࠓޙͷಈ͖͸Ͳ͏΍ͬͯݟ͍͚ͯ͹͍͍ͷʁ
    w ҠߦυΩϡϝϯτΛಡΊ͹ϦϦʔε͞Εͨ

    ৘ใ͸Θ͔ΔΑ͏ʹͳΓ·ͨ͠
    w ͜Ε͔Β௥Ճ͞ΕΔػೳͱ͔͸

    Ͳ͏΍ͬͯ஌Ε͹Α͍ͷͰ͠ΐ͏͔
    9

    View full-size slide

  10. 1)13'$
    w 3'$ͷϖʔδΛݟΔͱࠓޙͷಈ͖Λ

    νΣοΫͰ͖·͢
    w IUUQTXJLJQIQOFUSGD
    10

    View full-size slide

  11. 3'$ͷಈ͖
    w %SBGU%JTDVTTJPO7PUJOH
    w "DDFQUFE*NQMFNFOUBUJPO
    w %FDMJOF
    w ౤ථͷ݁Ռͷࢍ੒͕ͳ͍ͱ٫Լ͞ΕΔ
    11

    View full-size slide

  12. *NQMFNFOUFE
    12

    View full-size slide

  13. <>7PJE3FUVSO5ZQF
    w WPJE ໭Γ஋͕ͳ͍
    ΛϦλʔϯ

    λΠϓώϯτ͕ఆٛͰ͖ΔΑ͏ʹ
    13

    View full-size slide

  14. function process($data) :void
    {
    ...

    }
    14

    View full-size slide

  15. <>4VQQPSU$MBTT$POTUBOU7JTJCJMJUZ
    w Ϋϥεఆ਺ʹΞΫηεम০ࢠΛ

    ઃఆͰ͖ΔΑ͏ʹ͢Δ
    15

    View full-size slide

  16. class Foo
    {
    private const BAR = 'baz';
    }
    16

    View full-size slide

  17. "DDFQUFE
    1FOEJOH*NQMFNFOUFE

    17

    View full-size slide

  18. "MMPXTQFDJGZJOHLFZTJOMJTU

    w MJTU
    Ͱ࿈૝഑ྻͷΩʔΛࢦఆͯ͠

    ల։Ͱ͖ΔΑ͏ʹ͢Δ
    18

    View full-size slide

  19. list(
    'type' => $type,
    'value' => $value,
    ) = $attrs;
    19

    View full-size slide

  20. (FOFSBMJ[FTVQQPSUPGOFHBUJWFTUSJOHP⒎TFUT
    w จࣈྻͷΦϑηοτࢦఆʹϚΠφεͷ஋Λ

    ࢦఆͰ͖ΔΑ͏ʹ͢Δ
    w TVCTUSͳͲؔ਺Ͱ͸αϙʔτ͞Ε͍ͯͨ
    w ͍·ͷͱ͜Ζ൓ର͸Ͱ͍ͯͳ͍ͷͰ௨Γͦ͏
    21

    View full-size slide

  21. $str = 'abcdef';
    var_dump($str[-2]);
    // => string(1) "e"
    22

    View full-size slide

  22. 6OEFS%JTDVTTJPO
    23

    View full-size slide

  23. 5SBJUTXJUIJOUFSGBDFT
    w τϨΠτʹΠϯλʔϑΣΠεΛ

    ࣮૷Ͱ͖ΔΑ͏ʹ͢Δ
    w ͢͹Β͍͠
    w ͥͻ࣮૷͍͖͍ͯͨͩͨ͠
    24

    View full-size slide

  24. trait LoggerInjectTrait implements LoggerAwareInterface
    {
    protected $logger;
    /** @Inject */
    public function setLogger(LoggerInterface $logger)
    {
    $this->logger = $logger;
    }
    }
    25

    View full-size slide

  25. 1SPQFSUZ"DDFTTPST4ZOUBY
    w ΫϥεͷϓϩύςΟͷΞΫηαఆٛ
    w ΊͬͪΌཉ͔ͬͨ͠ͷʹͳΜͰ
    27

    View full-size slide

  26. $MBTT.FUBEBUB "OOPUBUJPOT

    w ΞϊςʔγϣϯͷωΠςΟϒαϙʔτ͸

    ٫Լ͞Ε͍ͯΔ
    w %PDίϝϯτͷΞϊςʔγϣϯΛѻ͏
    ʮ"OOPUBUJPOTJOEPDCMPDLʯ΋

    *OBDUJWFʹͳ͍ͬͯΔ
    28

    View full-size slide

  27. ·ͱΊΔͱ
    29

    View full-size slide

  28. 1)1υΩϡϝϯτΛಡ΋͏
    w ҠߦΨΠυΛಡΉͱϦϦʔεͷ಺༰͕

    ೺ѲͰ͖·͢
    w 3'$ΛಡΉͱࠓޙͷػೳ௥ՃͳͲͷಈ޲Λ

    ݟΔ͜ͱ͕Ͱ͖·͢
    30

    View full-size slide

  29. 1)1ΤϯδχΞͱ
    J04ΤϯδχΞͱ
    "OESPJEΤϯδχΞͱ
    σβΠφʔͱ
    ͱ΋͔͘Ұॹʹಇ͍ͯ͘ΕΔํΛืू͍ͯ͠·͢ʂʂ
    32

    View full-size slide