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
120
地方カンファレンス主催のススメ
bumptakayuki
1
160
Laravelで敢えて試す脆弱性のある書き方
bumptakayuki
1
790
地方でのPHPエンジニア採用って実際どうなの?
bumptakayuki
0
530
沖縄観光、名物を一挙紹介!
bumptakayuki
2
540
Laravel ShiftでLaravelのバージョンアップしてみた話
bumptakayuki
1
1.8k
flutterでイベントアプリを作ってみた
bumptakayuki
0
110
オフショア開発の辛みと学んだ事
bumptakayuki
0
340
ChatGPTにStripeのサンプルコードを書かせてみた
bumptakayuki
1
170
Other Decks in Technology
See All in Technology
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
Platform Engineering for Software Developers and Architects
syntasso
1
520
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.9k
Taming you application's environments
salaboy
0
200
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
200
静的解析で実現した効率的なi18n対応の仕組みづくり
minako__ph
1
110
Chasing the White Whale of Open Source - ROI
mrbobbytables
0
100
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
3
350
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
270
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
450
Application Development WG Intro at AppDeveloperCon
salaboy
0
200
Featured
See All Featured
Bash Introduction
62gerente
608
210k
BBQ
matthewcrist
85
9.3k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Six Lessons from altMBA
skipperchong
27
3.5k
A designer walks into a library…
pauljervisheath
204
24k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Why Our Code Smells
bkeepers
PRO
334
57k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Side Projects
sachag
452
42k
The Language of Interfaces
destraynor
154
24k
Fireside Chat
paigeccino
34
3k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
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. ·ͱΊ ͜ΕͳΒɺ෭ۀɺϑϦʔϥϯεɺΦϑγϣΞ ͍ΖΜͳਓ͕ೖͬͯ҆৺ʂʂʂʂ