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.7k
LaravelとNuxt.jsで保守性を高める構成を考えてみた
LaravelとNuxt.jsで保守性を高める構成を考えてみた
Takayuki
May 29, 2021
Tweet
Share
More Decks by Takayuki
See All by Takayuki
エンジニアのキャリア論
bumptakayuki
0
130
地方カンファレンス主催のススメ
bumptakayuki
1
170
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
860
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
570
沖縄観光、名物を一挙紹介!
bumptakayuki
2
570
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
2k
flutterでイベントアプリを作ってみた
bumptakayuki
0
120
オフショア開発の辛みと学んだ事
bumptakayuki
0
350
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
180
Other Decks in Technology
See All in Technology
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
6
54k
大規模言語モデルとそのソフトウェア開発に向けた応用 (2024年版)
kazato
2
450
Amazon Q Developerで.NET Frameworkプロジェクトをモダナイズしてみた
kenichirokimura
1
130
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
1
5k
知っててうれしい HTTP Cookie を使ったセッション管理について
greendrop
1
110
Google Cloud で始める Cloud Run 〜AWSとの比較と実例デモで解説〜
risatube
PRO
0
140
React Routerで実現する型安全なSPAルーティング
sansantech
PRO
4
880
怖くない!ゼロから始めるPHPソースコードコンパイル入門
colopl
0
240
.NET AspireでAzure Functionsやクラウドリソースを統合する
tsubakimoto_s
0
140
シフトライトなテスト活動を適切に行うことで、無理な開発をせず、過剰にテストせず、顧客をビックリさせないプロダクトを作り上げているお話 #RSGT2025 / Shift Right
nihonbuson
3
1.5k
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
3
500
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.7k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
The World Runs on Bad Software
bkeepers
PRO
66
11k
It's Worth the Effort
3n
183
28k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
The Language of Interfaces
destraynor
155
24k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Designing Experiences People Love
moore
139
23k
YesSQL, Process and Tooling at Scale
rocio
170
14k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Bash Introduction
62gerente
609
210k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
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. ·ͱΊ ͜ΕͳΒɺ෭ۀɺϑϦʔϥϯεɺΦϑγϣΞ ͍ΖΜͳਓ͕ೖͬͯ҆৺ʂʂʂʂ