Laravelにおける後悔しないためのアプリケーション設計
by
localdisk
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Laravelʹ͓͚Δ ޙչ͠ͳ͍ͨΊͷ ΞϓϦέʔγϣϯઃܭ Laravel Osaka 2016 @localdisk
Slide 2
Slide 2 text
ࣗݾհ দඌେ ·͓ͭ·͞Δ EEE ΤϯδχΞ Πϊϕʔλʔδϟύϯॴଐ ΤϯδχΞɾσβ ΠφɾσΟϨΫλΛืूத ධൃചத @localdisk
Slide 3
Slide 3 text
ืूͯ͠·͢ʂʂʂ
Slide 4
Slide 4 text
ޙչ͠ͳ͍ΞϓϦέʔγϣϯઃܭ ͱ?
Slide 5
Slide 5 text
όάΛग़͞ͳ͍།Ұͷํ๏ϓϩάϥϜΛॻ͔ͳ͍͜ͱͩ ʕϓϩάϥϚͷ֨ݴʕ
Slide 6
Slide 6 text
ͦ͏͍͏Θ͚ʹ͍͔ͳ͍
Slide 7
Slide 7 text
ݱ࣮ݫ͍͠
Slide 8
Slide 8 text
ଥڠͯ͠ γϯϓϧ͞Λͨͭ
Slide 9
Slide 9 text
• ޙչ͠ͳ͍ͨΊʹͲ͏͢Δ͔? • FacadeΛ߇͑ͯΈΔ • Named Routes • FormRequest • ControllerͰEloquentͷϝιουνΣΠϯېࢭ • Repository Pattern Agenda
Slide 10
Slide 10 text
FacadeΛ߇͑ͯΈΔ
Slide 11
Slide 11 text
• ੩తϝιουͷΑ͏ʹ͑Δ • ࣮ࡍαʔϏείϯςφ͔ΒऔΓग़͍ͯ͠Δ • Ͳ͔͜ΒͰ͑Δ • ViewͷதͰ • \Auth::check() • ݁ՌɺΫϥεͷ͕େ͖͘ͳΔ Facade ศར͚ͩͲ…
Slide 12
Slide 12 text
https://readouble.com/laravel/5.3/ja/facades.html#facade-class-reference DIΛ͓͏
Slide 13
Slide 13 text
ͳΔ͘ Contract ͓͏ DIΛ͓͏(2)
Slide 14
Slide 14 text
• Facade Λ͏͔ΘΓʹ DI Λ͢Δͱ༻͢Δͱ ϝιουͷҾʹ༻͢ΔΫϥε͕ฒͿ • ͋ɺ͍ɻͱΘ͔Δɻ • FacadeΛܦ༝͠ͳ͍ͷͰएׯૣ͘ͳΔ ͳͥ DI ͔?
Slide 15
Slide 15 text
Named Routes
Slide 16
Slide 16 text
• Routeʹ໊લΛ͚ͭΔ • route(‘osaka’); ͰURL͕औಘͰ͖Δ • URL͕มΘͬͯ҆৺ Named Routes
Slide 17
Slide 17 text
FormRequest
Slide 18
Slide 18 text
গͣͭ͠هड़ྔ͕ݮ͍ͬͯΔ ͔͠͠ϊΠζʹͳ͍ͬͯΔͷ൱Ίͳ͍ Validation ͷมભ
Slide 19
Slide 19 text
• php artisan make:request Ϋϥε໊ • rulesϝιουΛ࣮ FormRequest
Slide 20
Slide 20 text
• ControllerͰϝιουΠϯδΣΫγϣϯ͢Δ͚ͩ • ϊΠζ͕ফ͑ͯϩδοΫʹूதͰ͖Δ FormRequest
Slide 21
Slide 21 text
ControllerͰEloquentͷ ϝιουνΣΠϯېࢭ
Slide 22
Slide 22 text
Model Binding
Slide 23
Slide 23 text
ʮಉ݁͡ՌΛAPIͰฦͤΔΑ͏ʹ͠ͱ͍ͯͶʯ ͱݴΘΕͨΒ…ʁ ControllerͰϝιουνΣΠϯμϝʂ
Slide 24
Slide 24 text
ModelʹΫΤϦΛด͡ࠐΊΔ
Slide 25
Slide 25 text
Repository Pattern
Slide 26
Slide 26 text
• Eloquent User::find ͷΑ͏ʹ੩తʹݺ ·͕͢ɺFacadeͰͳ͍ɻ • ΑͬͯshouldRecieveͱ͍͏ϝιουଘࡏ͠ ͳ͍ • EloquentDBʹґଘ͍ͯ͠Δ • ςετ͕ࠔΔ ͳͥ Repository Pattern?
Slide 27
Slide 27 text
• ΠϯλʔϑΣʔεΛఆٛ Repository Patternͷ࡞Γํ
Slide 28
Slide 28 text
• ΠϯλʔϑΣʔεΛ࣮ɻ͋ͱίϯτϩʔϥͰΠ ϯδΣΫγϣϯ͢Δ Repository Patternͷ࡞Γํ
Slide 29
Slide 29 text
࣭ͱ͔ʁ
Slide 30
Slide 30 text
͓ΘΓ