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ͱ͍͏ϝιου͸ଘࡏ͠ ͳ͍ • Eloquent͸DBʹґଘ͍ͯ͠Δ • ςετ͕ࠔΔ ͳͥ 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

͓ΘΓ