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とNuxt.jsで保守性を高める構成を考えてみた
Search
Takayuki
May 29, 2021
Technology
1
1.6k
LaravelとNuxt.jsで保守性を高める構成を考えてみた
LaravelとNuxt.jsで保守性を高める構成を考えてみた
Takayuki
May 29, 2021
Tweet
Share
More Decks by Takayuki
See All by Takayuki
エンジニアのキャリア論
bumptakayuki
0
100
地方カンファレンス主催のススメ
bumptakayuki
1
150
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
710
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
510
沖縄観光、名物を一挙紹介!
bumptakayuki
2
520
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
1.6k
flutterでイベントアプリを作ってみた
bumptakayuki
0
110
オフショア開発の辛みと学んだ事
bumptakayuki
0
330
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
160
Other Decks in Technology
See All in Technology
令和最新版 Perlコーディングガイド
anatofuz
4
4k
What a Good Platform Looks Like and How to Get There @ Large Financial Organization, Oct 2024
mfpais
PRO
0
100
【完全版】Dify - LINE Bot連携 考え方と実用テクニック
uezo
2
600
CData Virtuality を活かせるキーシナリオと製品デモ
cdataj
0
300
入門 バックアップ
ryuichi1208
18
7.1k
OPENLOGI Company Profile for engineer
hr01
1
12k
プロダクト開発の貢献をアピールするための目標設計や認知活動 / Goal design and recognition activities to promote product development contributions.
oomatomo
5
940
Oracle Database 23ai 新機能#4 Real Application Clusters
oracle4engineer
PRO
0
170
見えづらい活動の成果の伝え方は日頃からめちゃくちゃ悩んでるけど、実際こんな取り組みをしな がら温度感を合わせにいってるよ / Conveying Hard-to-See Results
kakehashi
4
2k
Cosmos DB で持続可能な RAG を実現しよう!~ AOAI Dev Day ふりかえりを添えて / Sustainable RAG with Cosmos DB with recap AOAI Dev Day
miyake
0
120
From naive to advanced RAG: the complete guide
glaforge
0
260
JAWS PANKRATION 2024 配信システムの紹介
yoshimi0227
0
100
Featured
See All Featured
Fireside Chat
paigeccino
32
3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
39
2.1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Unsuck your backbone
ammeep
668
57k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
The Invisible Side of Design
smashingmag
297
50k
A designer walks into a library…
pauljervisheath
202
24k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
59k
The Mythical Team-Month
searls
218
43k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
Transcript
鈴木孝之 LaravelͱNuxt.jsͰอकੑΛ ߴΊΔߏΛߟ͑ͯΈͨ
"HFOEB ࣗݾհ -BSBWFM7VFKTͰͷ41"։ൃͷ՝ײ ߟ͑ͯΈͨϓϩδΣΫτߏ 'BU$POUSPMMFSΛ͙
Copyright Re:Build.inc All Rights Reserved. ରऀʹ͍ͭͯ 0 -BSBWFMͱ7VFKT/VYUKTΛ͍ͬͯΔ σΟϨΫτϦߏͳͲΛࡧத ՄಡੑɾอकੑΛ্͍͛ͨ
ॳڃऀʙதڃऀ͚
Copyright Re:Build.inc All Rights Reserved. ͢͜ͱɾ͞ͳ͍͜ͱ 0 -BSBWFMத৺ͷઃܭʹ͍ͭͯ 7VFKT/VYUKTͷઃܭʹ͍ͭͯ গ͠
σΟϨΫτϦߏͳͲ ͢͜ͱ ͞ͳ͍͜ͱ ΠϯϑϥपΓͷৄ͍͠ ϚωδϝϯτɾνʔϜମ੍ ͳͲ
ࣗݾհɾձࣾհ
Copyright Re:Build.inc All Rights Reserved. ࣗݾհ 1 ◆໊લ ླ ೭(Suzuki
Takayuki) ※ಉಉ໊ଟͯ͘ࠔͬͯ·͢ɻɻɻ ◆ࣗݾհ ɾ1990ੜ·Εɻ ɾΤϯδχΞˠϑϦʔϥϯεˠԭೄͰىۀ ɾPHPΧϯϑΝϨϯεԭೄ࣮ߦҕһɺ ϑϩϯτΤϯυΧϯϑΝϨϯεԭೄ࣮ߦҕһ ◆झຯ ίεϓϨɺԻָϥΠϒɺϚϥιϯେձʹग़Δɺٿ؍ઓ BDD(Ϗʔνۦಈ։ൃ)
Copyright Re:Build.inc All Rights Reserved. ࣗݾհ 1
Copyright Re:Build.inc All Rights Reserved. ࣗݾհ 1
Copyright Re:Build.inc All Rights Reserved. ധ̏Ͱ։࠵ʂࣾ֎ͷํ ߹ಉͰ։ൃͯ͠·͢ʂ ϦϏϧυԭೄ։ൃ߹॓ 1
Copyright Re:Build.inc All Rights Reserved. ϦϏϧυԭೄ։ൃ߹॓ 1
Copyright Re:Build.inc All Rights Reserved. ࣗݾհ 1
Copyright Re:Build.inc All Rights Reserved. ձࣾհ 1 ◆ձ໊ࣾ גࣜձࣾRe:Build ◆ॅॴ
ԭೄݝಹࢢٱໜ2-2-2 λΠϜεϏϧ ◆ࣄۀ༰ ɾࣗࣾWEBαʔϏεͷاըɾ։ൃɻ ɾडୗ։ൃ ɾϓϩάϥϛϯάεΫʔϧ ◆ࣾһ 11໊ ΤϯδχΞืूͯ͠·͢ʂʂʂ
Copyright Re:Build.inc All Rights Reserved. 1 3 ɾαʔϏε໊ Tadoru https://tadoru.work/
ɾγεςϜ֓ཁ ΤϯδχΞಛԽܕͷ ϦϑΝϥϧ Ϋϥυιʔγϯά 1 ձࣾհ
Copyright Re:Build.inc All Rights Reserved. 1 4 ɾαʔϏε໊ ROLEMO https://rolemo.net/
ɾγεςϜ֓ཁ ༷ʑͳΩϟϦΞͷΤϯδχΞʹ ΩϟϦΞ૬ஊͰ͖ΔαʔϏε 1 ձࣾհ
Copyright Re:Build.inc All Rights Reserved. อकੑͱ - อक࡞ۀΛ࣮ࢪ͢Δ͜ͱͰɺػೳঢ়ଶ͕ҡ࣋͞ΕΔੑ࣭ɻ ·ͨɺͦͷ༰қ͞ɻ -
ιϑτΣΞͷ߹ʹɺޡΓෆ۩߹ͷൃݟɾमਖ਼ͷ͠ ͢͞ɺࣄલʹ༧ఆ͞Ε͍ͯͳ͔༷ͬͨมߋػೳՃͳ Ͳͷߦ͍͢͞ɺιʔείʔυͷಡΈ͢͞ͱ͍͕ͬͨத ৺ͱͳΔɻ https://e-words.jp/w/%E4%BF%9D%E5%AE%88%E6%80%A7.html
Copyright Re:Build.inc All Rights Reserved. αϚϦ - ܕϦΫΤετɾϨεϙϯεΛՄࢹԽͯ͠ɺΤϥʔͷΓ͚Λ͘͢͢͠ Δɻ -
LintΛ͔ͬ͠Γಋೖ͢Δ͜ͱͰɺେਓΦϑγϣΞ։ൃͳͲͷϓϩδΣΫτ Ͱॻ͖ํΛ౷Ұ͢Δɻ - ֤ͷׂΛϋοΩϦͤͯ͞ɺίʔυΛಡΈ͘͢͢ΔɻFat Controllerආ͚ Δɻ อकੑΛߴΊΔʹʁ
Copyright Re:Build.inc All Rights Reserved. ্͢Ͱͷલఏ - ։ൃنத͘Β͍͕ଟ͍ɻ - ̏ʙ̒ਓͰʙ1։ൃϓϩδΣΫτ͕ଟ͍ɻ
- େنϓϩδΣΫτগͳ͍ɻ ฐࣾʹ͓͚Δ։ൃϓϩδΣΫτͷಛ
-BSBWFM7VFKTͰͷ41"։ൃͷ՝ײ
Copyright Re:Build.inc All Rights Reserved. 2 SPA։ൃͷ՝ ϑϩϯτΤϯυͱόοΫ ΤϯυͰܕͷ߹ੑΛ୲ อ͍ͨ͠
SPAͷσΟϨΫτϦ ߏͬͯϕετϓϥΫςΟ εΛݟ͚ͭΔͷ͕͍͠ Laravel/Vue.jsࣗ༝ʹॻ͚Δ ɺͪΌΜͱϧʔϧΛܾΊͳ͍ͱ ͙ͪΌ͙ͪΌʹͳΓ͕ͪ
Copyright Re:Build.inc All Rights Reserved. ෭ۀɺϑϦʔϥϯεɺΦϑγϣΞɺ৽ਓͳͲ ͍ΖΜͳਓ͕ϓϩδΣΫτʹࢀը͍ͯ͠Δ߹ɺ ϧʔϧ͕͔ͬ͠Γ͍ͯ͠ͳ͍ͱɺ ίʔυ͕εύήςΟʹͳΓ͕ͪʂʂʂ 2
ෳਓ։ൃϓϩδΣΫτͷ՝
ߟ͑ͯΈͨϓϩδΣΫτߏ
2 2 બఆٕͨ͠ज़ ▪ٕज़ཁ݅ ɾαʔόαΠυ PHP(Laravel) ɾϑϩϯτΤϯυ Vue.js,Nuxt.js TypeScript ɾςετ
PHPUnit ɾ੩తղੳ ESlint,Stylelint PHPStan,phpcs,phpmd ɾΠϯϑϥ AWS(EC2,S3,RDS(mariadb)) ɾ։ൃڥ php7,nginx,mariadb,docker,webpack ɾͦͷଞ gitlab,gitlabCI(ࣗಈσϓϩΠͳͲ)
ϑϩϯτΤϯυ αʔόαΠυ શମߏ(ࣗࣾαʔϏε OREIO) Gitlab CI ςετɾLintͳͲ ςετɾLintͳͲ ֤lint
(1)PUSH (2)GitlabCI࣮ߦ (3)ίϯςφىಈ Gitlab (6)Envoy࣮ߦ ςετ࣮ߦ ίϯςφ σϓϩΠ࣮ߦ ίϯςφ (5)ίϯςφىಈ
(4)UnitTest࣮ߦ (7)Pull εςʔδϯάڥ ϦϙδτϦ Gitlab CI
ϑϩϯτΤϯυ શମߏ(ৄࡉ) αʔόαΠυ(API) ϒϥβ͔ΒΞΫηε Component HTML CSS JS Pages request.ts
response.ts Types Resouce.php APIϦΫΤετ APIϨεϙϯε ϦΫΤετɾϨεϙϯεͷ ܕΛఆٛ Request.php router controller Model Database router όϦσʔγϣϯ ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ Libs/api/index.ts Enum ਵ࣌༻
Laravelͷߏʹ͍ͭͯ
Laravelߏ(ৄࡉ) αʔόαΠυ ϒϥβ͔Β ΞΫηε HTML CSS JS View Resouce.php APIϦΫΤετ
APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ Enum ਵ࣌༻
αʔόαΠυ Resouce.php APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ
ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ ControllerͰग़͖ͯ ͨϩδοΫΛmodel ʹدͤΔ ϒϥβ͔Β ΞΫηε HTML CSS JS View Laravelߏ(ৄࡉ) Enum ਵ࣌༻
αʔόαΠυ Resouce.php APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ
ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ ֎෦αʔϏεΛୟ͘ Α͏ͳॲཧService ʹॻ͘ ϒϥβ͔Β ΞΫηε HTML CSS JS View Laravelߏ(ৄࡉ) Enum ਵ࣌༻
αʔόαΠυ Resouce.php APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ
ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ ϒϥβ͔Β ΞΫηε HTML CSS JS View Laravelߏ(ৄࡉ) Enum ਵ࣌༻ DBͰఆٛ͢Δ΄ͲͰ ͳ͍Α͏ͳఆܥ Enumʹॻ͘
αʔόαΠυ Resouce.php APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ
ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ Enum ਵ࣌༻ ό Ϧ σ ʔ γ ϣ ϯ RequestΫϥεʹॻ͘ ϒϥβ͔Β ΞΫηε HTML CSS JS View Laravelߏ(ৄࡉ)
αʔόαΠυ Resouce.php APIϦΫΤετ APIϨεϙϯε Request.php router controller Model όϦσʔγϣϯ ϨεϙϯεΛ
ఆٛ Service αʔυύʔςΟ Repository Logic Ϗδωεɾ ϩδοΫ σʔλɾ ΞΫηε Database ϒϥβ͔Β ΞΫηε HTML CSS JS View Laravelߏ(ͬͱɺେنʹͳ͖ͬͯͨΒ) Enum ਵ࣌༻
LaravelͷσΟϨΫτϦߏ
LaravelͷσΟϨΫτϦߏ(֤σΟϨΫτϦͷղઆ) ※ؾʹͳΔਓޙͰಡΜͰ͓͍͍ͯͩ͘͞ɻ
LaravelͷσΟϨΫτϦߏ(֤σΟϨΫτϦͷղઆ) ※ؾʹͳΔਓޙͰಡΜͰ͓͍͍ͯͩ͘͞ɻ
ϦϙδτϦύλʔϯͬͯͲ͏ͳͷʁ ϦϙδτϦύλʔϯͱ(Ҿ༻) υϝΠϯۦಈܕઃܭͷҰͭͱͯ͠ಋೖ͞Εͨ ͷͰɺσʔλιʔεͷΞΫηεͷநԽ Λఏڙ͢ΔͷͰ͢ɻ ͦΕͧΕҟͳΔੑ࣭Λ࣋ͭσʔλιʔεʹର ͯ͠ڞ௨ͷΠϯλʔϑΣΠεΛఆٛͦ͠ΕΛ ϦϙδτϦͱ࣮ͯ͢͠ΔࣄͰɺ Ϗδωεϩ δοΫ͔ΒσʔλΞΫηεΛʢૄ݁߹ʣ
ͤ͞ɺػೳͱͯ͠ͷ֦ுੑɾอकੑΛ্͞ ͤΔࣄ͕Ͱ͖·͢ɻ https://deha.co.jp/magazine/introducing-laravel-repository/
ϦϙδτϦύλʔϯͷ͍ॴ User UserRepositoryInterface UserMysqlRepository UserSqliteRepository ɾσʔλιʔεͷΞΫηεɾૢ࡞ʹؔͯ͠ʮSELECTʯʮINSERTʯʮUPDATEʯʮDELETEʯͳͲ͕͋Γ· ͕͢ɺͦΕΒͷૢ࡞ྫ͑RDBMSͱNoSQLͰจ๏ͷҧ͍͕͋ΔͷͰɺ͜ΕΒͷૢ࡞ͷҝʹࢲୡ͕ॻ͘ίʔ υʹͦΕͧΕҧ͍͕͋Γ·͢ɻ ͜ΕΒΛڞ௨ͷΠϯλʔϑΣΠεΛ࣋ͨͤΔࣄͰɺϏδωεଆͰͲͷσʔ λιʔε͔ΛҙࣝͤͣʹσʔλଆΛѻ͏ࣄ͕Ͱ͖ΔΑ͏ʹͳΔɻ
https://www.ritolab.com/entry/165
ϦϙδτϦύλʔϯͷ͍ॴ̎ Report ϓϩδΣΫτڞ௨Ͱ͏Α͏ͳܭࢉॲཧΛ·ͱΊͯɺఆ͓ٛͯ͘͠ɻ ɾCalculationImpression() ɾCalculationCvr() ɾCalculationCtr() AdDataRepositoryInterface AdDataRepository
ϦϙδτϦύλʔϯͷϝϦοτɾσϝϦοτ RepositoryύλʔϯͷϝϦοτ - νʔϜͰιʔεͷ։ൃɾอक͕͠қ͍ - σʔλͷߏஙɺσʔλιʔεɺϏδωεϩδοΫʹมߋ͕ൃੜ͢Δ߹ɺιʔεͷมߋ͕গͳ ͘ࡁΉ - ϏδωεϩδοΫͱσʔλιʔεΛ͚ͯɺςετ͢Δࣄ͕Ͱ͖Δ RepositoryύλʔϯͷσϝϦοτ
- ίʔυྔ͕ଟ͘ͳΔ - খنͷҊ݅ͩͱɺٯʹϝϯςφϯείετ͕ߴ͘ͳΔɻ
ϦϙδτϦύλʔϯΛ࣮ࡍɺͬͯΈͯͲ͏͔ͩͬͨʁ - ॳظஈ֊ͰෳࡶͳΫΤϦ͕গͳ͍߹ɺۭͬΆʹ͍ۙΫϥε͕ͨ͘͞Μ૿͑ ͯ͠·ͬͨɻ - ݁ہɺ໘ʹͳͬͨͷͰɺഇࢭ
αʔϏεΫϥεͬͯͲ͏ͳͷʁ αʔϏεΫϥεͱʁ UI ͔Β͚ͩͰͳ͘ɺCUIͷϓϩάϥϜͱ͔ ଞγεςϜͱͷ࿈ܞ෦ͱ͔Ͱɺڞ௨ͷϩ δοΫΛݺͿඞཁ͕͋Δͱ͖ʹɺService ϨΠϠʔӽ͠ʹυϝΠϯϩδοΫΛॲཧ͢ Δͱɺڞ௨ͷΠϯλϑΣʔεͰૢ࡞Ͱ͖Δ Α͏ʹͳΔ https://martinfowler.com/eaaCatalog/serviceLayer.html
αʔϏεΫϥεͷ͍ํ ྫ͑ɺStripe APIΛͬͨ ߪೖɾΩϟϯηϧॲཧͳͲΛ ॻ͍͍ͯ͘ https://martinfowler.com/eaaCatalog/serviceLayer.html
αʔϏεΫϥεΛ࣮ࡍɺͬͯΈͯͲ͏͔ͩͬͨʁ - ֎෦αʔϏε(API)ͳͲΛୟ͘ॲཧ͚ͩ·ͱΊΔͷͰɺϩδοΫͷৼΓ͚ ͍͢͠ɻ - ModelϦϙδτϦΫϥεͰॻ͘Α͏ͳॲཧͱඃΒͳ͍ͷͰɺΘ͔Γ͢ ͍ɻ - தنϓϩδΣΫτͰಋೖͯ͠த͕ബ͘ͳΒແͦ͞͏ɻ
ϑϩϯτΤϯυ શମߏ αʔόαΠυ(API) ϒϥβ͔ΒΞΫηε͠ɺ ϢʔβIDͱύεϫʔυΛೖྗ Component HTML CSS JS Pages
request.ts response.ts Types Resouce.php APIϦΫΤετ APIϨεϙϯε ϦΫΤετɾϨεϙϯεͷ ܕΛఆٛ Request.php router controller Model Database router όϦσʔγϣϯ ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ Libs/api/index.ts
όοΫΤϯυΤϯυ σΟϨΫτϦߏ ϦΫΤετɾ Ϩεϙϯε
όοΫΤϯυ Request.php όϦσʔγϣϯϧʔϧΛ ఆٛ͢Δ
όοΫΤϯυ Resource.php Ϩεϙϯε͕ՄࢹԽ͞Ε͍ͯΔɻ ඞཁͳ͚ͩฦͬͯ͘Δ
Tips - Open APIΛͬͯɺAPI༷ॻ݉ Swaggerͱͯ͠͏ͱศརɻ - ϑϩϯτΤϯυͱόοΫΤϯυଆͰ ϦΫΤετɾϨεϙϯεͷڞ௨ೝࣝΛ࣋ ͯΔɻ -
࠷ѱɺόοΫΤϯυ͕Ԇ͍ͯ͠Δ࣌ ͜ͷAPI༷Λࢀߟʹϑϩϯτͷ։ൃ ΛਐΊͨΓͯͨ͠ɻ https://swagger.io/resources/articles/documenting-apis-with-swagger/
Vue.js/Nuxt.jsͷߏʹ͍ͭͯ
NuxtͷσΟϨΫτϦߏ
ϑϩϯτΤϯυ શମߏ αʔόαΠυ(API) ϒϥβ͔ΒΞΫηε͠ɺ ϢʔβIDͱύεϫʔυΛೖྗ Component HTML CSS JS Pages
request.ts response.ts Types Resouce.php APIϦΫΤετ APIϨεϙϯε ϦΫΤετɾϨεϙϯεͷ ܕΛఆٛ Request.php router controller Model Database router όϦσʔγϣϯ ϨεϙϯεΛ ఆٛ Service αʔυύʔςΟ Libs/api/index.ts
ϑϩϯτΤϯυ σΟϨΫτϦߏ APIͷϦΫΤετɾϨε ϙϯεͷఆٛ ϛυϧΣΞ APIϦΫΤετ constͳͲ AxiosϥΠϒ ϥϦͳͲ
ϑϩϯτΤϯυ request.ts ܕΛinterfaceͰఆٛ
ϑϩϯτΤϯυ index.ts APIΛϦΫΤετ
ΞτϛοΫσβΠϯͬͯͲ͏ͳͷʁ ΞτϛοΫσβΠϯͱʁ 5ͭͷ֊ʹ͚ɺ࠷ऴతͳUIͱUIͷجૅͱͳΔ σβΠϯγεςϜΛಉ࣌ʹ࡞͢Δઃܭํ๏ɻ - ݪࢠʢAtomʣ: ࠷খཻ͍͞ͷཁૉ - ࢠʢmoleculeʣ: 2ͭҎ্ͷݪࢠΛΈ߹Θͤͨγϯ
ϓϧͳUIཁૉ - ༗ػମʢorganismʣ: Γͯ͠୯ମͰػೳ͢Δ ࢠͷू·Γ - ςϯϓϨʔτʢTemplatesʣ: ͍͔ͭ͘ͷ༗ػମɾ ࢠɾݪࢠ͔ΒΓཱ͍ͬͯΔࠎΈ - ϖʔδʢPagesʣ: ςϯϓϨʔτʹ࣮ࡍͷίϯςϯπ Λద༻ͨ͠ͷ https://uxdaystokyo.com/articles/glossary/atomic-design/
ΞτϛοΫσβΠϯͬͯͲ͏ͳͷʁ ͬͯΈͨײ - ࡉ͔͘ͲͷίʔυΛ5ʹৼΓ͚Δ͔ͷஅ͕͍͠ɻ - ্ख͘ৼΓ͚ΒΕͳ͍ͱ͔͑ͬͯɺΑ͘Θ͔Βͳ͘ͳͬͯ ͠·ͬͨɻ - զʑʹ·ͩΞτϛοΫσβΠϯૣ͔ͬͨɻϓϩδΣΫτ ʹ༗ࣝऀ͕͍ͳ͍ͱ͍͠ɻ
ΞτϛοΫσβΠϯͬͯͲ͏ͳͷʁ ࠷ऴతʹͲ͏͔ͨ͠ʁ - σβΠϯγεςϜͷ୯ҐͰίϯ ϙʔωϯτΛ͍ͬͯ͘ͱཧ͕ Ͱ͖ͨɻ - ͳͷͰɺॳظஈ֊ͰσβΠφʔ͞ ΜʹͪΌΜͱσβΠϯγεςϜΛ ࡞ͬͯΒ͏͜ͱΛ͓નΊ͠·
͢ɻ
LintͷઃఆͳͲ
ϑϩϯτΤϯυ αʔόαΠυ ֤lintͷઃఆ Gitlab CI ςετɾLintͳͲ ςετɾLintͳͲ ֤lint
੩తղੳͷઃఆ phpcs.xml - PSR12ͷνΣο ΫͳͲ
੩తղੳͷઃఆ phpmd.xml - ίʔυαΠζͷνΣοΫ - ΘΕ͍ͯͳ͍ίʔυͷ νΣοΫ - ม໊ͳͲͷνΣοΫ
੩తղੳͷઃఆ eslint - AirbnbͷJavaScript Style GuideΛίʔσΟϯάنͱ ͢Δɻ - Prettier ͳͲ
https://www.wantedly.com/companies/askul/post_articles/155377
੩తղੳͷઃఆ stylelint - CSSͷߏจΤϥʔ - ϑΥʔϚοτͱҰ؏ੑ - ελΠϧͷॏෳΛݮΒ͢ ͳͲ https://www.webprofessional.jp/taking-css-linting-next-level-stylelint/
'BU$POUSPMMFSΛ͙
ɾFatControllerʢଠͬͨίϯτϩʔϥʣͷ͜ͱͰ͢ɻͳΜͰଠΔ͔ͱݴ͏ͱ୲͏͕ଟ͍ ͔ΒͰ͢ɻྫ͑ɺԼهͷΑ͏ͳཧ༝͕ߟ͑ΒΕ·͢ɻ ɾෳͷϝιουͰॲཧ͕ॏෳ͍ͯ͠Δɻ ɾ୯७ʹΞΫγϣϯϝιου͕ଟ͍ɻ ɾϩδοΫ͕ଟ͗͢Δɻ ɾͻͱͭͷมߋ͕ଞͷ෦ʹٴ΅͢ӨڹΛݕͮ͠Β͍ঢ়ଶʹ͋Δ Fat Controller ͱʁ
ɾControllerͷͷൣғ֎ͷॲཧೖ͖ͬͯͯ͠·͏ɻ ɹɹControllerͷ ɹɹ- ೖྗʢHTTPϦΫΤετʣΛड͚औΓɺνΣοΫ͢Δ ɹɹ- దͳॲཧܥΛ͢ ɹɹ- ϨεϙϯεΛฦ͢ ɹɹͷ̏ͭͱݴΘΕ͍ͯ·͢ɻ ɾҰͭҰͭͷॲཧ͕ͯ͘ɺॲཧΛ͏ͷ͕͍͠ɻ
ɾॲཧͷॏෳ͕ଟ͍ͷͰɺ༷มߋ͕͋ͬͨ࣌ʹमਖ਼͕͍͠ɻ Fat ControllerԿͰྑ͘ͳ͍ͷ͔ʁ https://eh-career.com/engineerhub/entry/2021/05/28/160000#Laravel%E3%81%AE%E4%BE%8B%E3%81%AB%E8%A6%8B%E3%82%8BFatModel
ϦϑΝΫλ༰
privateϝιουʹΓ͚Δ Ұͭͷϝιου͕50ߦΛ͑ͦ͏ͳ Βɺॲཧ͝ͱʹprivateϝιουʹ ͚Δ
modelΫϥεʹϩδοΫΛ͚Δ ControllerʹϩδοΫ͕૿͖͑ͯͨ ΒɺmodelʹॲཧΛ͚Δ
όϦσʔγϣϯRequestΫϥεʹॻ͘ ControllerʹόϦσʔγϣϯΛॻ ͖͠ͳ͍ͰRequestΫϥεͰॲཧ͢ Δ
ෳͷ Controller ʹ͢Δ ҰͭͷControllerͰΞΫγϣϯϝ ι ο υ ͕ ૿ ͑
͢ ͗ Δ ߹ ɺ ControllerϑΝΠϧ͝ͱ͚Δ
ϨεϙϯεͷσʔλΛResource ʹॻ͘ Ϩεϙϯεσʔλ͕ෳࡶԽ͖ͯͨ͠ ΓɺՃ͕ඞཁͳ߹ResouceΫ ϥεʹ͚Δ
ϦϑΝΫλ·ͱΊ ɾControllerͷͷൣғ֎ͷॲཧೖΕͳ͍ɻ ɾඞཁʹԠͯ͡ɺϩδοΫͷΛ૿͢ɻ ɾॲཧΛࡉԽͯ͠ɺॏෳ͢Δॲཧ·ͱΊΔɻ
Copyright Re:Build.inc All Rights Reserved. ·ͱΊ - ܕϦΫΤετɾϨεϙϯεΛՄࢹԽͯ͠ɺΤϥʔͷΓ͚Λ͘͢͢͠ Δɻ -
LintΛ͔ͬ͠Γಋೖ͢Δ͜ͱͰɺେਓΦϑγϣΞ։ൃͳͲͷϓϩδΣΫτ Ͱॻ͖ํΛ౷Ұ͢Δɻ - ֤ͷׂΛϋοΩϦͤͯ͞ɺίʔυΛಡΈ͘͢͢ΔɻFat Controllerආ͚ Δɻ อकੑΛߴΊΔʹʁ
Copyright Re:Build.inc All Rights Reserved. ·ͱΊ ͜ΕͳΒɺ෭ۀɺϑϦʔϥϯεɺΦϑγϣΞ ͍ΖΜͳਓ͕ೖͬͯ҆৺ʂʂʂʂ