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.7k
Laravelにおける後悔しないためのアプリケーション設計
laravel.osaka 2016 で発表したものです。
localdisk
November 02, 2016
Tweet
Share
More Decks by localdisk
See All by localdisk
about Laravel 5.3
localdisk
1
890
Laravel の効率的な学び方
localdisk
9
3.2k
逆引きLaravel
localdisk
7
13k
Other Decks in Programming
See All in Programming
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
880
subpath importsで始めるモック生活
10tera
0
300
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
660
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
For a Future-Friendly Web
brad_frost
175
9.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
A Tale of Four Properties
chriscoyier
156
23k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Building an army of robots
kneath
302
43k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
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ͷ࡞Γํ
࣭ͱ͔ʁ
͓ΘΓ