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

#phperkaigi 名著「パーフェクトPHP」のPart3に出てきたフレームワークを令和5年に書き直したらどんな感じですかね?

#phperkaigi 名著「パーフェクトPHP」のPart3に出てきたフレームワークを令和5年に書き直したらどんな感じですかね?

PHPerKaigi 2023の発表資料です
https://fortee.jp/phperkaigi-2023/proposal/db787adc-c855-4114-99b6-8c6958d47b42

参考文献・動画を、別途ブログ記事として記載しているのでそちらもぜひご覧ください
https://daisuki.nichiyoubi.land/entry/2023/03/11/221306

hideki kinjyo

March 23, 2023
Tweet

More Decks by hideki kinjyo

Other Decks in Programming

Transcript

  1. PHP
    Part3
    5
    PHPerKaigi 2023


    Hideki Kinjyo


    GitHub: o0h / Twitter: @o0h_


    [ൃද൛]

    View full-size slide

  2. ࣗݾ঺հ
    /
    GitHub: @o0h / Twitter: @o0h_
    FW CakePHP


    View full-size slide

  3. ⾠ΊͬͪΌग़ͯ͘Δ͚Ͳઆ໌͠ͳ͍֓೦
    DI
    PSR PHP-FIG
    PSR-7/15/17, PSR-11
    =>


    View full-size slide

  4. ༧Ίݴ͓ͬͯ͘͜ͱ
    
 

    ( )
    https://speakerdeck.com/o0h/phperkaigi-2023

    View full-size slide

  5. PHP
    HP

    https://gihyo.jp/book/2010/978-4-7741-4437-5

    View full-size slide

  6. ॻ੶ͷجຊ৘ใ
    2010 11 12
    Part-1: PHP overview / Part 2: PHP / Part 3:
    Web / Part 4: PHP /
    Part5: PHP / Part 6: PHP /
    Appendix

    10-11-12

    View full-size slide

  7. ύʔϑΣΫτPHPͱࢲ
    PHP 2
    1 PHP
    1
    PHP SQL
    MY ( )

    View full-size slide

  8. ύʔϑΣΫτPHPͱΈͳ͞Μ
    ( )
    PHP
    PHP
    1,2

    View full-size slide

  9. ύʔϑΣΫτPHPͱΈͳ͞Μ
    https://twitter.com/search?q= PHP
    https://qiita.com/search?q=" PHP"
    https://jp.mercari.com/search?keyword="
    PHP"

    View full-size slide

  10. ԿΑΓʮFWΛ࡞Δʯؚ͕·Ε͍ͯΔͷ͕(΋)ྑ͍
    Part-1: PHP overview / Part 2: PHP / Part
    3: Web / Part 4: PHP
    / Part5: PHP / Part 6: PHP /
    Appendix

    ⏳estimate: 2 /40

    View full-size slide

  11. PHP |
    http://blog.asial.co.jp/771
    1

    View full-size slide

  12. PHP |
    http://blog.asial.co.jp/771
    1

    View full-size slide

  13. ;Γ͔͑Δ: ύʔϑΣΫτPHP͸ԿΛ͘Εͨͷ͔
    FW FW
    IT
    1

    ⏳estimate: 3 /40

    View full-size slide

  14. ྩ࿨5೥ʹ࠶௅ઓͯ͠ΈΔ
    :
    10
    :
    PHP PHP

    View full-size slide

  15. ͓͠ͳ͕͖
    1. PHP Part3 FW
    2. 22 5 PHP
    3.
    FW
    4.

    View full-size slide

  16. §1 FW
    - PHP Part3 -

    View full-size slide

  17. ୊ࡐ: ϛχϒϩά
    1.
    2.
    3.
    4.

    ⏳estimate: 5 /40

    View full-size slide

  18. શମతͳઃܭ
    MVC
    URL


    ⏳estimate: 6 /40

    View full-size slide

  19. ϑϩϯτίϯτϩʔϥʔ(index.php)

    View full-size slide

  20. ϧʔςΟϯά(Application)
    Application

    View full-size slide

  21. ΞΫγϣϯͷσΟεύον(Application)
    Application ControllerAction

    ⏳estimate: 7.5 /40

    View full-size slide

  22. ΞΫγϣϯͷσΟεύονᶄ(Application)

    Response

    View full-size slide

  23. ΞΫγϣϯ(Controller)
    Request
    Model
    View

    View full-size slide

  24. ϦΫΤετͷѻ͍
    Request Session
    $_GET $_SESSION

    View full-size slide

  25. DBΞΫηε(DbManager, Repository)
    Repository
    Controller
    SQL RDB
    DbManager
    PDO
    Repository

    ⏳estimate: 9.5 /40

    View full-size slide

  26. ίϯςϯπͷඳը(View)
    View

    View full-size slide

  27. αʔόʔฦ౴(Response)
    Response
    header()
    echo

    View full-size slide

  28. ૯ׅ
    MVC


    ⏳estimate: 11 /40

    View full-size slide

  29. §2 PHP
    - 22 5 PHP -

    View full-size slide

  30. ࣥච͞Εͨ౰࣌ͱࠓ͸ɺͲΜͳҧ͍͕͋Δͷ͔
    FW MVC
    FW

    ⏳estimate: 11.5 /40

    View full-size slide


  31. 2010 PHP
    ⏳estimate: 12.5 /40



    View full-size slide


  32. namespace

    Standard Group



    View full-size slide



  33. Rails FW

    GitHub



    View full-size slide


  34. 2010 HipHop

    Composer+Packagist



    View full-size slide


  35. CI 2011
    ⏳estimate: 14 /40



    View full-size slide

  36. https://www.thoughtworks.com/content/dam/thoughtworks/documents/radar/
    2011/07/tr_technology_radar_vol_5_en.pdf

    View full-size slide


  37. Twelve-Factor App



    View full-size slide


  38. 3 PHP5

    Facebook Hack



    View full-size slide


  39. PHP7

    2 Phan PHPStan
    ⏳estimate: 15.5 /40



    View full-size slide

  40. 1. Composerͷొ৔ɾσϑΝΫτԽ
    PSR-0/4

    View full-size slide

  41. 2. ݎ࿚ͳίʔυ΁ͷཉٻ
    Hack
    PHP7( ) PHP8( )

    ⏳estimate: 16.5 /40

    View full-size slide

  42. 3. FWʹΑΔ”ࢧ഑”͔Βͷ཭൓ʁ
    10 Web
    ( )
    DB

    ⏳estimate: 17.5 /40

    View full-size slide

  43. §3 FW
    - 10 -

    View full-size slide


  44. FW

    ⏳estimate: 19.5 /40

    View full-size slide

  45. جຊํ਑
    FW
    (ORM View( etc)


    View full-size slide

  46. ந৅ʹΑΔઃܭ: ґଘੑͷ؅ཧ
    FW
    DI

    ⏳estimate: 20.5 /40

    View full-size slide

  47. γϯϓϦγςΟ: খ͞ͳ໾ׂΛ૊Έ߹ΘͤΔ
    CI/
    MVC
    Middleware Single Action(Controller)

    View full-size slide

  48. ڻ͖Λ཈͑Δ࣮૷: ෆมੑɺܕݕࠪ
    (= )

    View full-size slide

  49. ૬ޓӡ༻ੑ: PSRͷॏࢹ
    FW
    PSR

    ⏳estimate: 23.5 /40

    View full-size slide

  50. ⏳estimate: 24 /40

    View full-size slide

  51. ΍Δ͜ͱ
    FW

    FW
    : https://github.com/o0h/phperkaigi-2023
    Zenn

    View full-size slide

  52. ΍Βͳ͍͜ͱ
    FW
    ( Logger Cache )

    View full-size slide

  53. σΟϨΫτϦߏ੒ʹ͍ͭͯ
    FW

    ⏳estimate: 26.5 /40

    View full-size slide

  54. FWίʔυͷґଘύοέʔδ
    FW
    PSR
    11: Container
    17: HTTP Factory
    7: HTTP Message
    15: HTTP Server
    Request Handlers

    View full-size slide

  55. appίʔυͷґଘύοέʔδ
    FW repositories
    Composer

    ⏳estimate: 28.5 /40

    View full-size slide

  56. Applicationͷ੹຿
    Application

    View full-size slide

  57. ϛυϧ΢ΣΞϋϯυϥʔͷ࣮૷

    View full-size slide

  58. Emitterͷ࣮૷
    ( )Application
    PSR-7
    Emitter HTTP

    ⏳estimate: 29.5 /40

    View full-size slide


  59. ύʔϑΣΫτPHPͷॲཧ

    (ResponseΫϥε)

    View full-size slide


  60. PSR-7ResponseΛ࢖͏ॲཧ

    View full-size slide

  61. ϛυϧ΢ΣΞͷ࣮૷
    PSR-15 Middleware Interface

    ⏳estimate: 30.5 /40

    View full-size slide


  62. PSR-7ͷServerRequestʹ͸ແ͍

    Session৘ใΛ෇༩͢Δ

    (͘͢͝؆ૉͳ)Middlewareͷ࣮૷ྫ

    View full-size slide

  63. ϧʔςΟϯάͷมߋ
    URL
    1

    ⏳estimate: 31.5 /40

    View full-size slide


  64. ύʔϑΣΫτPHPͷॲཧ

    (ApplicationαϒΫϥε)

    View full-size slide


  65. ActionΛىಈͤ͞ΔϧʔςΟϯά

    (routes.php)

    View full-size slide

  66. Actionͷ੹຿
    Action
    (PSR-7)
    (PSR-7)

    ⏳estimate: 32 /40

    View full-size slide

  67. Actionͷ࢓ࣄʹඞཁͳґଘͷղܾ
    Action RoutingMiddleware

    DI Action
    PSR-11 DI
    DI PSR-11
    (=get(), has())

    View full-size slide


  68. ਌Ϋϥεʹɺ

    શͯͷActionͰڞ௨ͷॲཧΛهड़͠·͢

    View full-size slide


  69. ࢠΫϥεݻ༗ͷॲཧ͸ɺ

    `depends()`ͱ͍͏ϝιουΛ༻ҙͯ͠

    ґଘΛهड़Ͱ͖ΔΑ͏ʹ͠·ͨ͠

    View full-size slide


  70. depends()͸ɺ୯ͳΔηολʔͰ͢

    ࿈૝഑ྻͷల։(໊લ͖Ҿ਺)Λར༻͍ͯ͠·͢

    View full-size slide

  71. :

    Action

    Attribute

    View full-size slide

  72. Τϥʔϋϯυϥʔͷ࣮૷
    1

    try-catch
    PSR-15 Speci
    fi
    cation RECOMMENDED

    ⏳estimate: 34 /40

    View full-size slide


  73. ྫ֎Λัଊͯ͠ɺ

    ࣗ਎ͰResponseΛ૊Έཱͯͯฦ͔͢

    `ErrorAction`ʹॲཧΛ౉͢

    View full-size slide

  74. ͦͷଞʹ཈͓͖͍͑ͯͨϙΠϯτ
    (
    )
    PSR-7/PSR-17
    PSR-11 DI
    PSR-4 Autoloader

    ⏳estimate: 34 /40

    View full-size slide

  75. ͦͷଞʹ཈͓͖͍͑ͯͨϙΠϯτ
    PHP CSRF
    : Laravel/CakePHP/Slim
    CSRF

    View full-size slide

  76. ͦͷଞʹ཈͓͖͍͑ͯͨϙΠϯτ
    psr/***-implementation
    https://github.com/middlewares/psr15-middlewares

    View full-size slide

  77. ࠓճ΍Γ͔ͨͬͨ͜ͱɺͲ͏Ͱͨ͠ʁ
    PHP 10
    MVC
    Composer PSR DI
    /TDD
    PSR

    ⏳estimate: 37 /40

    View full-size slide

  78. ࠓճ΍Γ͔ͨͬͨ͜ͱɺͲ͏Ͱͨ͠ʁ
    FW
    PHP

    View full-size slide

  79. Zenn΋ॻ͜͏ͱͯ͠Δɾɾɾ
    ( )

    View full-size slide

  80. ͓͠·͍ʂ
    ͓෇͖߹͍͍͖ͨͩ

    ͋Γ͕ͱ͏͍͟͝·ͨ͠

    View full-size slide

  81. §X Appendix

    View full-size slide

  82. ίϛϡχςΟʹ஝ੵ͞Ε͍ͯΔ஌ݟ
    https://daisuki.nichiyoubi.land/entry/2023/03/11/221306

    View full-size slide

  83. ૬ޓӡ༻ੑɺඪ४ͷେࣄ͞
    PSR
    
 

    sizuhiko

    https://speakerdeck.com/sizuhiko/phpcon-fukuoka-2019

    View full-size slide

  84. PSR-7
    PSR-7

    sasezaki

    https://www.slideshare.net/sasezaki/httpphp

    View full-size slide

  85. PSR-7Λத৺ͱͯ͠PSR HTTPγϦʔζ
    PSR-7


    https://speakerdeck.com/tanakahisateru/17ninatutafalseka

    View full-size slide

  86. PSR-15/ϛυϧ΢ΣΞͷ۩ମɾ࣮૷


    https://tadsan.fanbox.cc/posts/3674121
    https://speakerdeck.com/n1215/psr-15-request-
    handlerkarali-jie-surumiddlewarefalseshi-zu-mi

    View full-size slide

  87. DI / DIίϯςφ
    DI DI

    PHPerKaigi2021


    https://speakerdeck.com/rukiadia/understand-
    dependency-injection-of-php
    https://speakerdeck.com/hiro_y/php-di-with-
    attributes

    View full-size slide

  88. DIίϯςφͷ۩ମɾ࣮૷
    DI

    2021

    https://tadsan.fanbox.cc/posts/2061773

    View full-size slide

  89. FW޿ൣ

    FW

    PHPerKaigi2018

    https://www.youtube.com/watch?v=mW4a2BKM3Kg

    View full-size slide