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

はじめてのモダンPHP

polidog
September 14, 2019

 はじめてのモダンPHP

polidog

September 14, 2019
Tweet

More Decks by polidog

Other Decks in Technology

Transcript

  1. ͸͡ΊͯͷϞμϯPHP
    Shizuoka.php #1 2019/09/14
    @polidog

    View Slide

  2. ࣗݾ঺հ
    • @polidog
    • ౦ژࡏॅɺग़਎͸ਗ਼ਫ۠
    • ύʔςΟʔϋʔυגࣜձࣾ औక໾ɾϓϩάϥϚ
    • ޷͖ͳϑϨʔϜϫʔΫ͸Symfony
    • ࠷ۙ࢖͍͍ͨϑϨʔϜϫʔΫ͸BEAR Sunday
    • Vue΋ͪΐ͍ͪΐ͍ॻ͍ͯ·͢

    View Slide

  3. ϞμϯPHP?

    View Slide

  4. View Slide

  5. http://
    ja.phptherightway.com/

    View Slide

  6. PHP The Right Way
    • ؾܰʹಡΊΔ(?)ΫΠοΫϦϑΝϨϯε
    • ϕετϓϥΫςΟε
    • ֤ݴޠʹ຋༁͞Ε͍ͯΔ(΋ͪΖΜ೔ຊޠ΋͋
    Δ)
    • ϞμϯͷجૅͱͳΔ͜ͱ͕ࡌ͍ͬͯΔ

    View Slide

  7. 18ݸͷϓϥΫςΟε
    • ͸͡Ίʹ
    • ίʔσΟϯάελΠϧ
    • ݴޠ࢓༷ͷϙΠϯτ
    • ґଘؔ܎ͷ؅ཧ
    • ίʔσΟϯάʹؔ͢Δश׳
    • ґଘੑ஫ೖ
    • σʔλϕʔε
    • ςϯϓϨʔτ
    • Τϥʔͱྫ֎ॲཧ
    • ηΩϡϦςΟ
    • ςετ
    • ֤छαʔό΁ͷσϓϩΠ
    • Ծ૝Խ
    • Ωϟογϡ
    • Documenting your CodeʢPHPDocʣ
    • ৘ใݯ
    • ίϛϡχςΟ

    View Slide

  8. ίʔσΟϯάελΠϧ

    View Slide

  9. PSR1,2,4
    • PSR1͸جຊίʔσΟϯάن໿
    • PSR2͸ίʔσΟϯάελΠϧΨΠυ
    • PSR4͸ΦʔτϩʔσΟϯάελϯμʔυ
    • ৄ͍͜͠ͱ͸͜ͷهࣄΛࢀর

    https://qiita.com/tadsan/items/
    942a381e952e12a8fa5a

    View Slide

  10. phpcs(PHP CodeSniffer)
    • ίʔυ͕४ڌ͍ͯ͠Δ͔νΣοΫͰ͖Δ
    • PHPStorm΍vscodeͱ࿈ܞͰ͖Δ

    https://qiita.com/suin/items/
    8f00ccd58f0464fb9791
    • phpcbfΛ࢖ͬͯίʔυΛमਖ਼

    View Slide

  11. php-cs-fixer
    • PSR1,2, SymfonyίʔσΟϯάن໿ʹԊͬͨܗʹ
    मਖ਼ͯ͘͠ΕΔ
    • @PSR1,@PSR2,@SymfonyͳͲͷϧʔϧηοτ

    https://github.com/FriendsOfPHP/PHP-CS-
    Fixer/blob/
    681806863baec9d874dae95dd0f9eb3db44e
    9b90/src/RuleSet.php

    View Slide

  12. ґଘؔ܎ͷ؅ཧ

    View Slide

  13. Comopser
    • npm΍bundlerΈ͍ͨͳ΋ͷ
    • composer.jsonʹґଘؔ܎Λهड़͢Δ
    • PEAR͸๻͸΋͏5೥Ҏ্࢖͍ͬͯͳ͍
    • ೔ຊ͔Βͩͱ஗͍

    https://qiita.com/keitakn/items/
    37f0fac49442b72c403e

    View Slide

  14. View Slide

  15. Packagist
    • https://packagist.org/
    • PHPͷύοέʔδΛ୳͢ҝͷαΠτ

    View Slide

  16. View Slide

  17. ύοέʔδͷߋ৽ʹ͍ͭͯ
    • libraries.ioΛ࢖͏

    https://libraries.io/
    • ηΩϡϦςΟνΣοΫ͸Security Advisories
    CheckerΛ࢖͏

    https://security.symfony.com/


    View Slide

  18. ґଘੑ஫ೖ

    View Slide

  19. ґଘੑ஫ೖ
    • ӳޠͩͱDIͱ͔Dependency Injectionͱ͔ݴΘΕΔ΍ͭ
    • ࠷ۙͷϑϨʔϜϫʔΫʹ͸DI͕͍͍ͩͨ༻ҙ͞Ε͍ͯΔ
    • ೉͍͠ͷͰଞͷDIͷઆ໌ΛಡΉ΂͖

    https://polidog.jp/2019/06/08/di/


    https://qiita.com/ritukiii/items/
    de30b2d944109521298fɹ

    View Slide

  20. ςετ

    View Slide

  21. PHPUnitͰϢχοτςετΛॻ͘
    • Ϣχοτςετ͸Ϋϥε΍ϝιου͕ظ଴௨Γʹಈ͍͍ͯ
    Δ͔Λ։ൃதʹ͔֬ΊΔɻ
    • ςετํ๏͸ೋ௨Γ
    • ೖग़ྗͷظ଴஋Λςετ͢Δ
    • ৼΔ෣͍Λ͔֬ΊΔͨΊͷςετ
    • ςετͷจԽ͕ͳ͍ͷͳΒ͹ϢχοτςετΛ·ͣ͸ॻ͍
    ͍ͯ͘ࣄ͕ॏཁ

    View Slide

  22. Prophecy
    • ϞοΫΦϒδΣΫτϑϨʔϜϫʔΫ
    • εύΠํࣜͰςετͰ͖Δ
    • ࢀߟ

    https://qiita.com/Hiraku/items/
    326b58c586a134d2ea74

    View Slide

  23. View Slide

  24. View Slide

  25. σϓϩΠ

    View Slide

  26. DeployerΛ࢖͏
    • PHP੡ͷσϓϩΠπʔϧ
    • σϓϩΠ༻ͷλεΫΛఆٛ͢Δ
    • ίϚϯυΛ࣮ߦ͢Δ͚ͩͰσϓϩΠͰ͖Δ
    • ֤छϑϨʔϜϫʔΫ༻ͷϨγϐ͕༻ҙ͞Ε͍ͯΔ
    • جຊతͳ࢖͍ํ

    https://www.tam-tam.co.jp/tipsnote/tool/post17066.html

    View Slide

  27. CIΛ࢖ͬͨσϓϩΠ
    • CIΛ࢖ͬͯdeployerΛಈ͔͢
    • ྫ͑͹CircleCIΛ࢖͏৔߹

    https://tech.quartetcom.co.jp/2017/01/04/
    deployer-on-circleci/

    View Slide

  28. ฐࣾͷσϓϩΠϑϩʔ
    PRͷ࡞੒
    ϚʔδϘλϯԡ͢
    deployer
    slackʹ௨஌

    View Slide

  29. View Slide

  30. ࠷ޙʹ

    View Slide

  31. ϞμϯPHPͰ։ൃ͢Δҙຯ

    View Slide

  32. ࿑ಇ࣌ؒΛݮΒͨ͢Ί

    View Slide

  33. ɹ?>

    View Slide