Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Laravelにおける後悔しないためのアプリケーション設計
Search
localdisk
November 02, 2016
Programming
8
5.8k
Laravelにおける後悔しないためのアプリケーション設計
laravel.osaka 2016 で発表したものです。
localdisk
November 02, 2016
Tweet
Share
More Decks by localdisk
See All by localdisk
about Laravel 5.3
localdisk
1
900
Laravel の効率的な学び方
localdisk
9
3.2k
逆引きLaravel
localdisk
7
13k
Other Decks in Programming
See All in Programming
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
testcontainers のススメ
sgash708
1
120
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
As an Engineers, let's build the CRM system via LINE Official Account 2.0
clonn
1
670
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
103 Early Hints
sugi_0000
1
220
The rollercoaster of releasing an Android, iOS, and macOS app with Kotlin Multiplatform | droidcon Italy
prof18
0
150
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
From Translations to Multi Dimension Entities
alexanderschranz
2
130
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Being A Developer After 40
akosma
87
590k
4 Signs Your Business is Dying
shpigford
181
21k
We Have a Design System, Now What?
morganepeng
51
7.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Building Your Own Lightsaber
phodgson
103
6.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
94
Transcript
Laravelʹ͓͚Δ ޙչ͠ͳ͍ͨΊͷ ΞϓϦέʔγϣϯઃܭ Laravel Osaka 2016 @localdisk
ࣗݾհ দඌେ ·͓ͭ·͞Δ EEE ΤϯδχΞ Πϊϕʔλʔδϟύϯॴଐ ΤϯδχΞɾσβ ΠφɾσΟϨΫλΛืूத ධൃചத
@localdisk
ืूͯ͠·͢ʂʂʂ
ޙչ͠ͳ͍ΞϓϦέʔγϣϯઃܭ ͱ?
όάΛग़͞ͳ͍།Ұͷํ๏ϓϩάϥϜΛॻ͔ͳ͍͜ͱͩ ʕϓϩάϥϚͷ֨ݴʕ
ͦ͏͍͏Θ͚ʹ͍͔ͳ͍
ݱ࣮ݫ͍͠
ଥڠͯ͠ γϯϓϧ͞Λͨͭ
• ޙչ͠ͳ͍ͨΊʹͲ͏͢Δ͔? • FacadeΛ߇͑ͯΈΔ • Named Routes • FormRequest •
ControllerͰEloquentͷϝιουνΣΠϯېࢭ • Repository Pattern Agenda
FacadeΛ߇͑ͯΈΔ
• ੩తϝιουͷΑ͏ʹ͑Δ • ࣮ࡍαʔϏείϯςφ͔ΒऔΓग़͍ͯ͠Δ • Ͳ͔͜ΒͰ͑Δ • ViewͷதͰ • \Auth::check()
• ݁ՌɺΫϥεͷ͕େ͖͘ͳΔ Facade ศར͚ͩͲ…
https://readouble.com/laravel/5.3/ja/facades.html#facade-class-reference DIΛ͓͏
ͳΔ͘ Contract ͓͏ DIΛ͓͏(2)
• Facade Λ͏͔ΘΓʹ DI Λ͢Δͱ༻͢Δͱ ϝιουͷҾʹ༻͢ΔΫϥε͕ฒͿ • ͋ɺ͍ɻͱΘ͔Δɻ • FacadeΛܦ༝͠ͳ͍ͷͰएׯૣ͘ͳΔ
ͳͥ DI ͔?
Named Routes
• Routeʹ໊લΛ͚ͭΔ • route(‘osaka’); ͰURL͕औಘͰ͖Δ • URL͕มΘͬͯ҆৺ Named Routes
FormRequest
গͣͭ͠هड़ྔ͕ݮ͍ͬͯΔ ͔͠͠ϊΠζʹͳ͍ͬͯΔͷ൱Ίͳ͍ Validation ͷมભ
• php artisan make:request Ϋϥε໊ • rulesϝιουΛ࣮ FormRequest
• ControllerͰϝιουΠϯδΣΫγϣϯ͢Δ͚ͩ • ϊΠζ͕ফ͑ͯϩδοΫʹूதͰ͖Δ FormRequest
ControllerͰEloquentͷ ϝιουνΣΠϯېࢭ
Model Binding
ʮಉ݁͡ՌΛAPIͰฦͤΔΑ͏ʹ͠ͱ͍ͯͶʯ ͱݴΘΕͨΒ…ʁ ControllerͰϝιουνΣΠϯμϝʂ
ModelʹΫΤϦΛด͡ࠐΊΔ
Repository Pattern
• Eloquent User::find ͷΑ͏ʹ੩తʹݺ ·͕͢ɺFacadeͰͳ͍ɻ • ΑͬͯshouldRecieveͱ͍͏ϝιουଘࡏ͠ ͳ͍ • EloquentDBʹґଘ͍ͯ͠Δ
• ςετ͕ࠔΔ ͳͥ Repository Pattern?
• ΠϯλʔϑΣʔεΛఆٛ Repository Patternͷ࡞Γํ
• ΠϯλʔϑΣʔεΛ࣮ɻ͋ͱίϯτϩʔϥͰΠ ϯδΣΫγϣϯ͢Δ Repository Patternͷ࡞Γํ
࣭ͱ͔ʁ
͓ΘΓ