Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LaravelのFat Controllerをどうリファクタしていくか

Takayuki
August 25, 2021

LaravelのFat Controllerをどうリファクタしていくか

LaravelのFat Controllerをどうリファクタしていくか

Takayuki

August 25, 2021
Tweet

More Decks by Takayuki

Other Decks in Programming

Transcript

  1. Copyright Re:Build.inc All Rights Reserved. ձࣾ঺հ 1 ◆ձ໊ࣾ גࣜձࣾRe:Build ◆ॅॴ

    ԭೄݝಹ೼ࢢٱໜ஍2-2-2 λΠϜεϏϧ ◆ࣄۀ಺༰ ɾࣗࣾWEBαʔϏεͷاըɾ։ൃɻ ɾडୗ։ൃ ◆ࣾһ 10໊ ◆ΤϯδχΞͷಇ͖ํ ϦϞʔτϫʔΫՄೳͳࣗ༝ͳಇ͖ํΛਪ঑ͯ͠·͢ʂ
  2. Copyright Re:Build.inc All Rights Reserved. 9 ɾαʔϏε໊ Tadoru
 https://tadoru.work/
 


    ɾγεςϜ֓ཁ ΤϯδχΞಛԽܕͷ ϦϑΝϥϧ Ϋϥ΢υιʔγϯά 1 ձࣾ঺հ
  3. Copyright Re:Build.inc All Rights Reserved. 1 0 ɾαʔϏε໊ Re:Build Boot

    Camp
 https://rebuild-bootcamp.jp/
 
 ɾ֓ཁ ԭೄͱٶ࡚Ͱʮ࣮຿ϨϕϧʯΛ໨ ࢦ͢ํ޲͚ͷϓϩάϥϛϯάε Ϋʔϧ ɾ࢖͏ٕज़ LaravelɺVue.jsͳͲ 1 ձࣾ঺հ
  4. Copyright Re:Build.inc All Rights Reserved. 11 ࣮຿Ϩϕϧ ॳ৺ऀ ॳڃऀ ஍ํͷॳ৺ऀ޲͚ͷϓϩάϥ

    ϛϯάεΫʔϧΛଔۀͨ͠ޙ ͷॳڃऀ͔Β࣮຿Ϩϕϧ·Ͱ ͷؒΛຒΊΔεΫʔϧ 1 ձࣾ঺հ
  5. 1 8 Fat Controller͸ԿͰྑ͘ͳ͍ͷ͔ʁ ɾControllerͷ੹຿ͷൣғ֎ͷॲཧ΋ೖ͖ͬͯͯ͠·͏ɻ Controllerͷ੹຿͸ - ೖྗʢHTTPϦΫΤετʣΛड͚औΓɺνΣοΫ͢Δ - ద੾ͳॲཧܥ΁஋Λ౉͢

    - ϨεϙϯεΛฦ͢ ͷ̏ͭͱݴΘΕ͍ͯ·͢ɻ ɾҰͭҰͭͷॲཧ͕௕ͯ͘ɺॲཧΛ௥͏ͷ͕೉͍͠ɻ ɾॲཧͷॏෳ͕ଟ͍ͷͰɺ࢓༷มߋ͕͋ͬͨ࣌ʹमਖ਼͕೉͍͠ɻ 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
  6. શମߏ੒(ཧ૝) αʔόαΠυ ϒϥ΢β͔Β ΞΫηε Component HTML CSS JS bladeͳͲ Resouce.php

    APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ Ϩεϙϯε஋Λ ఆٛ Service αʔυύʔςΟ MPA Events Enum ਵ࣌࢖༻
  7. શମߏ੒(ཧ૝) αʔόαΠυ ϒϥ΢β͔Β ΞΫηε Component HTML CSS JS bladeͳͲ Resouce.php

    APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ Ϩεϙϯε஋Λ ఆٛ Service αʔυύʔςΟ MPA Events Enum ਵ࣌࢖༻ ControllerͰग़͖ͯ ͨϩδοΫΛmodel ʹدͤΔ
  8. શମߏ੒(ཧ૝) αʔόαΠυ ϒϥ΢β͔Β ΞΫηε Component HTML CSS JS bladeͳͲ Resouce.php

    APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ Ϩεϙϯε஋Λ ఆٛ Service αʔυύʔςΟ MPA Events Enum ਵ࣌࢖༻ ֎෦αʔϏεΛୟ͘ Α͏ͳॲཧ͸Service ʹॻ͘
  9. શମߏ੒(ཧ૝) αʔόαΠυ ϒϥ΢β͔Β ΞΫηε Component HTML CSS JS bladeͳͲ Resouce.php

    APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ Ϩεϙϯε஋Λ ఆٛ Service αʔυύʔςΟ MPA Events Enum ਵ࣌࢖༻ DBͰఆٛ͢Δ΄ͲͰ ͸ͳ͍Α͏ͳఆ਺ܥ ͸Enumʹॻ͘
  10. શମߏ੒(ཧ૝) αʔόαΠυ ϒϥ΢β͔Β ΞΫηε Component HTML CSS JS bladeͳͲ Resouce.php

    APIϦΫΤετ APIϨεϙϯε Request.php router controller Model Database όϦσʔγϣϯ Ϩεϙϯε஋Λ ఆٛ Service αʔυύʔςΟ MPA Events Enum ਵ࣌࢖༻ ό Ϧ σ ʔ γ ϣ ϯ ͸ RequestΫϥεʹॻ͘
  11. શମߏ੒(΋ͬͱେن໛ʹͳ͖ͬͯͨΒ) αʔόαΠυ ϒϥ΢β͔Β ΞΫηε Component HTML CSS JS bladeͳͲ Resouce.php

    APIϦΫΤετ APIϨεϙϯε Request.php router controller Model όϦσʔγϣϯ Ϩεϙϯε஋Λ ఆٛ Service αʔυύʔςΟ MPA Events Enum ਵ࣌࢖༻ Repository Logic Ϗδωεɾ ϩδοΫ σʔλɾ ΞΫηε Database
  12. 3 0 ᶇෳ਺ͷ Controller ʹ෼཭͢Δ ҰͭͷControllerͰΞΫγϣϯϝ ι ο υ ͕

    ૿ ͑ ͢ ͗ Δ ৔ ߹ ͸ ɺ ControllerϑΝΠϧ͝ͱ෼͚Δ