Slide 1

Slide 1 text

PHP Part3 5 PHPerKaigi 2023 Hideki Kinjyo GitHub: o0h / Twitter: @o0h_ 
 
 [ൃද൛]

Slide 2

Slide 2 text

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


Slide 3

Slide 3 text

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


Slide 4

Slide 4 text

༧Ίݴ͓ͬͯ͘͜ͱ 
 
 ( ) https://speakerdeck.com/o0h/phperkaigi-2023

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

ॻ੶ͷجຊ৘ใ 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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

;Γ͔͑Δ: ύʔϑΣΫτPHP͸ԿΛ͘Εͨͷ͔ FW FW IT 1 ⏳estimate: 3 /40

Slide 15

Slide 15 text

PHP

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

§1 FW - PHP Part3 -

Slide 19

Slide 19 text

୊ࡐ: ϛχϒϩά 1. 2. 3. 4. ⏳estimate: 5 /40

Slide 20

Slide 20 text

demo

Slide 21

Slide 21 text

શମతͳઃܭ MVC URL 
 ⏳estimate: 6 /40

Slide 22

Slide 22 text

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

ϧʔςΟϯά(Application) Application

Slide 25

Slide 25 text

ΞΫγϣϯͷσΟεύον(Application) Application ControllerAction ⏳estimate: 7.5 /40

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

ΞΫγϣϯ(Controller) Request Model View

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

DBΞΫηε(DbManager, Repository) Repository Controller SQL RDB DbManager PDO Repository ⏳estimate: 9.5 /40

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

૯ׅ MVC 
 ⏳estimate: 11 /40

Slide 33

Slide 33 text

§2 PHP - 22 5 PHP -

Slide 34

Slide 34 text

ࣥච͞Εͨ౰࣌ͱࠓ͸ɺͲΜͳҧ͍͕͋Δͷ͔ FW MVC FW ⏳estimate: 11.5 /40

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

2010 PHP ⏳estimate: 12.5 /40

Slide 38

Slide 38 text

PSR-0 PHP6

Slide 39

Slide 39 text

namespace 
 Standard Group

Slide 40

Slide 40 text


 Rails FW 
 GitHub

Slide 41

Slide 41 text

2010 HipHop 
 Composer+Packagist

Slide 42

Slide 42 text

CI 2011 ⏳estimate: 14 /40

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

Twelve-Factor App

Slide 45

Slide 45 text

3 PHP5 
 Facebook Hack

Slide 46

Slide 46 text

PHP7 
 2 Phan PHPStan ⏳estimate: 15.5 /40

Slide 47

Slide 47 text

( )

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

2. ݎ࿚ͳίʔυ΁ͷཉٻ Hack PHP7( ) PHP8( ) ⏳estimate: 16.5 /40

Slide 50

Slide 50 text

3. FWʹΑΔ”ࢧ഑”͔Βͷ཭൓ʁ 10 Web ( ) DB ⏳estimate: 17.5 /40

Slide 51

Slide 51 text

§3 FW - 10 -

Slide 52

Slide 52 text


 FW 
 ⏳estimate: 19.5 /40

Slide 53

Slide 53 text

جຊํ਑ FW (ORM View( etc) 美

Slide 54

Slide 54 text

ந৅ʹΑΔઃܭ: ґଘੑͷ؅ཧ FW DI ⏳estimate: 20.5 /40

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

૬ޓӡ༻ੑ: PSRͷॏࢹ FW PSR ⏳estimate: 23.5 /40

Slide 58

Slide 58 text

§4 FW - -

Slide 59

Slide 59 text

⏳estimate: 24 /40

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

΍Δ͜ͱ FW 
 FW : https://github.com/o0h/phperkaigi-2023 Zenn

Slide 62

Slide 62 text

΍Βͳ͍͜ͱ FW ( Logger Cache )

Slide 63

Slide 63 text

σΟϨΫτϦߏ੒ʹ͍ͭͯ FW ⏳estimate: 26.5 /40

Slide 64

Slide 64 text

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

Slide 65

Slide 65 text

appίʔυͷґଘύοέʔδ FW repositories Composer ⏳estimate: 28.5 /40

Slide 66

Slide 66 text

Applicationͷ੹຿ Application

Slide 67

Slide 67 text

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

Slide 68

Slide 68 text

Slide 69

Slide 69 text

Emitterͷ࣮૷ ( )Application PSR-7 Emitter HTTP ⏳estimate: 29.5 /40

Slide 70

Slide 70 text

ύʔϑΣΫτPHPͷॲཧ 
 (ResponseΫϥε)

Slide 71

Slide 71 text

PSR-7ResponseΛ࢖͏ॲཧ

Slide 72

Slide 72 text

ϛυϧ΢ΣΞͷ࣮૷ PSR-15 Middleware Interface ⏳estimate: 30.5 /40

Slide 73

Slide 73 text

PSR-7ͷServerRequestʹ͸ແ͍ 
 Session৘ใΛ෇༩͢Δ 
 (͘͢͝؆ૉͳ)Middlewareͷ࣮૷ྫ

Slide 74

Slide 74 text

ϧʔςΟϯάͷมߋ URL 1 ⏳estimate: 31.5 /40

Slide 75

Slide 75 text

ύʔϑΣΫτPHPͷॲཧ 
 (ApplicationαϒΫϥε)

Slide 76

Slide 76 text

ActionΛىಈͤ͞ΔϧʔςΟϯά 
 (routes.php)

Slide 77

Slide 77 text

Actionͷ੹຿ Action (PSR-7) (PSR-7) ⏳estimate: 32 /40

Slide 78

Slide 78 text

Actionͷ࢓ࣄʹඞཁͳґଘͷղܾ Action RoutingMiddleware 
 DI Action PSR-11 DI DI PSR-11 (=get(), has())

Slide 79

Slide 79 text

਌Ϋϥεʹɺ 
 શͯͷActionͰڞ௨ͷॲཧΛهड़͠·͢

Slide 80

Slide 80 text

ࢠΫϥεݻ༗ͷॲཧ͸ɺ 
 `depends()`ͱ͍͏ϝιουΛ༻ҙͯ͠ 
 ґଘΛهड़Ͱ͖ΔΑ͏ʹ͠·ͨ͠

Slide 81

Slide 81 text

depends()͸ɺ୯ͳΔηολʔͰ͢ 
 ࿈૝഑ྻͷల։(໊લ͖Ҿ਺)Λར༻͍ͯ͠·͢

Slide 82

Slide 82 text

: 
 Action 
 Attribute

Slide 83

Slide 83 text

Τϥʔϋϯυϥʔͷ࣮૷ 1 
 try-catch PSR-15 Speci fi cation RECOMMENDED ⏳estimate: 34 /40

Slide 84

Slide 84 text

ྫ֎Λัଊͯ͠ɺ 
 ࣗ਎ͰResponseΛ૊Έཱͯͯฦ͔͢ 
 `ErrorAction`ʹॲཧΛ౉͢

Slide 85

Slide 85 text

ͦͷଞʹ཈͓͖͍͑ͯͨϙΠϯτ ( ) PSR-7/PSR-17 PSR-11 DI PSR-4 Autoloader ⏳estimate: 34 /40

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

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

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

ࠓճ΍Γ͔ͨͬͨ͜ͱɺͲ͏Ͱͨ͠ʁ PHP 10 MVC Composer PSR DI /TDD PSR ⏳estimate: 37 /40

Slide 90

Slide 90 text

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

Slide 91

Slide 91 text

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

Slide 92

Slide 92 text

͓͠·͍ʂ ͓෇͖߹͍͍͖ͨͩ 
 ͋Γ͕ͱ͏͍͟͝·ͨ͠

Slide 93

Slide 93 text

§X Appendix

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text

૬ޓӡ༻ੑɺඪ४ͷେࣄ͞ PSR 
 
 sizuhiko https://speakerdeck.com/sizuhiko/phpcon-fukuoka-2019

Slide 96

Slide 96 text

PSR-7 PSR-7 
 sasezaki https://www.slideshare.net/sasezaki/httpphp

Slide 97

Slide 97 text

PSR-7Λத৺ͱͯ͠PSR HTTPγϦʔζ PSR-7 
 https://speakerdeck.com/tanakahisateru/17ninatutafalseka

Slide 98

Slide 98 text

PSR-15/ϛυϧ΢ΣΞͷ۩ମɾ࣮૷ 
 https://tadsan.fanbox.cc/posts/3674121 https://speakerdeck.com/n1215/psr-15-request- handlerkarali-jie-surumiddlewarefalseshi-zu-mi

Slide 99

Slide 99 text

DI / DIίϯςφ DI DI 
 PHPerKaigi2021 
 https://speakerdeck.com/rukiadia/understand- dependency-injection-of-php https://speakerdeck.com/hiro_y/php-di-with- attributes

Slide 100

Slide 100 text

DIίϯςφͷ۩ମɾ࣮૷ DI 
 2021 https://tadsan.fanbox.cc/posts/2061773

Slide 101

Slide 101 text

FW޿ൣ 
 FW 
 PHPerKaigi2018 https://www.youtube.com/watch?v=mW4a2BKM3Kg