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 Vietnam Meetup 2022: Your code is simpl...
Search
Dinh Quoc Han
March 25, 2023
Technology
0
110
Laravel Vietnam Meetup 2022: Your code is simplify or complexity?
Laravel Vietnam Meetup (August 2022) at Ho Chi Minh City, Vietnam
Dinh Quoc Han
March 25, 2023
Tweet
Share
More Decks by Dinh Quoc Han
See All by Dinh Quoc Han
Laravel Live Vietnam 2022: Laravel Eloquent Performance
dinhquochan
0
48
Laravel Offline Sharing (March 2023) at Ho Chi Minh City, Vietnam
dinhquochan
0
48
Other Decks in Technology
See All in Technology
Node-RED × MCP 勉強会 vol.1
1ftseabass
PRO
0
150
本が全く読めなかった過去の自分へ
genshun9
0
540
Observability в PHP без боли. Олег Мифле, тимлид Altenar
lamodatech
0
350
セキュリティの民主化は何故必要なのか_AWS WAF 運用の 10 の苦悩から学ぶ
yoh
1
170
"サービスチーム" での技術選定 / Making Technology Decisions for the Service Team
kaminashi
1
140
急成長を支える基盤作り〜地道な改善からコツコツと〜 #cre_meetup
stefafafan
0
120
Tech-Verse 2025 Keynote
lycorptech_jp
PRO
0
220
AWS テクニカルサポートとエンドカスタマーの中間地点から見えるより良いサポートの活用方法
kazzpapa3
2
550
Amazon Bedrockで実現する 新たな学習体験
kzkmaeda
2
580
A2Aのクライアントを自作する
rynsuke
1
170
OpenHands🤲にContributeしてみた
kotauchisunsun
1
450
登壇ネタの見つけ方 / How to find talk topics
pinkumohikan
5
520
Featured
See All Featured
Building an army of robots
kneath
306
45k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
Optimizing for Happiness
mojombo
379
70k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
4 Signs Your Business is Dying
shpigford
184
22k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Designing Experiences People Love
moore
142
24k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Raft: Consensus for Rubyists
vanstee
140
7k
Transcript
Your Code Is SIMPLIFY Or COMPLEXITY? with Dinh Quoc Han
Code Của Bạn ĐƠN GIẢN Hay PHỨC TẠP? với Đinh
Quốc Hân
Who Am I? PHP Lover, Artisan 6 years experience Currently
working at SHIFT ASIA Admin at Laravel Viet Nam
Overview 1. Problems 2. Coding Standards 3. CRUD 4. Complexity?
5. Q&A
1. Problems!
2. Coding Standards
PSR-12
None
None
How to follow PSR-12?
None
PSR-12
composer require --dev laravel/pint
3. CRUD Create - Read - Update - Delete 😎
How Many?
M-V-C
M-V-C but by Packages
Domain Oriented Design Not ‘DDD’ - Domain Driven Design 🤣
…
Basic Example
routes/web.php
app/Http/Controllers/UserController.php
app/Http/Controllers/UserController.php
Write all business logic in controller?
None
Why?
Controller should hold ZERO logic!
Controller only bring logic together!
Easy apply design patterns, structures!
Easy to reuse, maintenance, testing
1. Fat Model - Thin Controller
None
None
None
2. Repository Class or Service Class
None
None
3. Actions/Commands Class (CQRS)
None
None
4. Together
Example From Laravel
None
None
Next: Controller!
Cruddy by Design Adam Wathan
"More controllers doing less work obviates need for many other
fancy patterns!" David Heinemeier Hansson - Creator of RoR
7 Standard Actions in Laravel
1. Index 2. Create 3. Store 4. Show 5. Edit
6. Update 7. Destroy
NEVER write CUSTOM ACTION
None
None
None
Tip #1: Nested Resource? Create New Controller
None
None
Tip #2: Edited Dependently? Create New Controller
None
None
Tip #3: Touches Pivot Records? Create New Controller
None
None
Tip #4: Transitions State? Create New Controller
Example From Laravel
None
None
Or Single Action Controller? Invokable Controller
None
None
4. Complexity?
YAGNI "You aren't gonna need it"
Back To The BASIC
app/Http/Controllers/UserController.php
1 Phút Quảng Cáo!
None
Thank You Q&A