Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Laravelにおける後悔しないためのアプリケーション設計
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
localdisk
November 02, 2016
Programming
6.1k
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Laravelにおける後悔しないためのアプリケーション設計
laravel.osaka 2016 で発表したものです。
localdisk
November 02, 2016
More Decks by localdisk
See All by localdisk
about Laravel 5.3
localdisk
1
1k
Laravel の効率的な学び方
localdisk
9
3.4k
逆引きLaravel
localdisk
7
14k
Other Decks in Programming
See All in Programming
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
220
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
200
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.2k
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
2
550
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
180
SREの越境 / SRE Collaboration
y0hgi
2
310
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
640
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
260
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Code Review Best Practice
trishagee
74
20k
Making the Leap to Tech Lead
cromwellryan
135
10k
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ͷ࡞Γํ
࣭ͱ͔ʁ
͓ΘΓ