Save 37% off PRO during our Black Friday Sale! »

CIフレンドリなDBドキュメント生成ツールでドキュメントの最新を維持し続ける / phpconfuk_rej

CIフレンドリなDBドキュメント生成ツールでドキュメントの最新を維持し続ける / phpconfuk_rej

【非公式】PHPカンファレンス福岡2018前夜祭リジェクトコン #phpconfuk_rej

69b93af68320a590f607c296e8edff73?s=128

Ken’ichiro Oyama

June 16, 2018
Tweet

Transcript

  1. খࢁ݈Ұ࿠(.01FQBCP *OD 1)1ΧϯϑΝϨϯε෱Ԭલ໷ࡇϦδΣΫτίϯ $*ϑϨϯυϦͳ%#υΩϡϝϯτੜ੒πʔϧͰ υΩϡϝϯτͷ࠷৽Λҡ࣋͠ଓ͚Δ  

  2. γχΞΤϯδχΞ খࢁ݈Ұ࿠!L-P8 ϗεςΟϯάࣄۀ෦ϗεςΟϯάάϧʔϓϚωʔδυΫϥ΢υνʔϜ IUUQTHJUIVCDPNL-P8  

  3. օ͞ΜͷϓϩδΣΫτʹ͸ σʔλϕʔεઃܭॻ΍&3ਤ͸ ͋Γ·͔͢ʁ

  4. ͦΕ͸ߋ৽͞Ε͍ͯ·͔͢ʁ ࠷৽ͷঢ়ଶͰ͔͢ʁ

  5. ࠷ۙࢲ͕+0*/ͨ͠ ͋ΔϓϩδΣΫτͷ৔߹

  6.  

  7. ͋ΔϓϩδΣΫτ -0-*101ϚωʔδυΫϥ΢υ ͷྫ w΋ͷ͍͢͝੎͍Ͱػೳ௥Ճ΍վળ͕܁Γฦ͞Ε͍ͯͨ w͍ΘΏΔ5JFSͳ୯७ͳ8FCΞϓϦέʔγϣϯͳͲͰ͸ͳ͘ɺϩʔϧ ͚ͩͰ΋ऑ΋͋Δɺ͍ΘΏΔ.JDSPTFSWJDFͳߏ੒ wͦͷ͏ͪॏཁͳঢ়ଶอ࣋Λ୲͏σʔλϕʔε͕ϩʔϧ wνʔϜϝϯόʔ͕༏लͰ͋Δ͜ͱ͔ΒσʔλϕʔεͷεΩʔϚมߋ΋ ;͘Ίಉ࣌ฒߦతʹߦΘΕ͍ͯͨ

  8. ͋ΔϓϩδΣΫτ -0-*101ϚωʔδυΫϥ΢υ ͷྫ wίʔυͷ؅ཧ͸(JU)VC ()& Ͱશͯ؅ཧ wΤϯδχΞ͚ͩͰͳ͘σβΠφʔ΋σΟϨΫλʔ΋(JU)VC্Ͱ׆ಈ wϓϩδΣΫτΛߏ੒͢ΔϦϙδτϦ͸ෳ਺ wϓϩάϥϛϯάݴޠ͸ͭͰ͸ͳ͘5ZQF4DSJQU΍(PͳͲෳ਺

  9. ଎͘ฒߦతͳ։ൃͷσʔλϕʔεεΩʔϚͷߋ৽՝୊ w୭΋͕σʔλϕʔεεΩʔϚͷશͯΛ೺Ѳ͍ͯ͠Δঢ়گͰ͸ͳ͔ͬͨ w ʮ͜ͷΧϥϜ͸ͲΜͳ༻్Ͱ࢖ΘΕΔΜͰ͔͢ʁʢࣗ෼ʣʯ w 4MBDLͰؾܰʹ࣭໰Ͱ͖Δ͠ɺௐ΂ͨΒΘ͔Δɻ͔͠͠ϫϯςϯϙ஗ΕΔ w୭΋͕σʔλϕʔεεΩʔϚͷ࠷৽ͷঢ়ଶΛ೺Ѳ͍ͯ͠Δঢ়گͰ͸ͳ ͔ͬͨ w ʮ͋ΕʁԶ͕࡞ͬͨϚΠάϨʔγϣϯ͕ద༻͞Εͯͳ͍ʯˠฒߦͰϚΠάϨʔγϣ

    ϯ͕ൃੜ͢Δ1VMM3FRVFTU͕͋ͬͨ݁ՌɺϚΠάϨʔγϣϯπʔϧͷϑΝΠϧ໊ ͷλΠϜελϯϓνΣοΫͰඈ͹͞Ε͍ͯͨ
  10. ࠷ॳͷࣗ෼ͷ޻෉ wνʔϜʹ+0*/ͨ͠͹͔ΓͰσʔλϕʔεͷશମ૾͕Θ͔Βͳ͔ͬͨ wͱΓ͋͑ͣ4DIBNB4QZΛ࢖ͬͯखݩʹσʔλϕʔευΩϡϝϯτΛ ࡞੒ͯ͠౎౓֬ೝ͍ͯͨ͠ wIUUQTDIFNBTQZPSH wશςʔϒϧશΧϥϜʹ$0..&/5Λ௥Ճ͢Δ1VMM3FRVFTUΛ͢ΔͳͲ wͱΓ͋͑ͣ҆৺

  11. ͱ͜Ζ͕ɺ͋Δͱ͖

  12. ϓϩμΫτΦʔφʔ ʮͲ͔͜ʹσʔλϕʔεઃܭॻͳ͍Ͱ͔͢Ͷʁʯ

  13. ΤϯδχΞͰͳͯ͘΋42-Λۦ࢖͢Δձࣾͩͬͨ wσʔλϕʔεΛ೺Ѳ͍ͨ͠ͷ͸ΤϯδχΞ͚ͩͰ͸ͳ͔ͬͨ w։ൃ͍ͯ͠ΔΤϯδχΞ͸σʔλϕʔεͷεΩʔϚʹ͍ͭͯ࠷৽Ͱ͸ ͳ͍ʹͤΑ೺Ѳ͍ͯ͠Δʢ͠ͳ͍ͱ։ൃͰ͖ͳ͍ʣ w࣭໰΍֬ೝΛ͢Δͱ͖ʹ΋ΞλϦ͕͚ͭΒΕΔ wීஈผͷ͜ͱΛߟ͑Δඞཁ͕͋ΔσΟϨΫλʔ͸ͦ͏Ͱ͸ͳ͍ w͜Ε͸ʢྑ͍ҙຯͰʣ૝ఆ֎ɺ͜ͷ··ͩͱϚζ͍͔΋

  14. UCMT

  15. UCMT wUCMTJTB$*'SJFOEMZUPPMGPSEPDVNFOUBEBUBCBTF XSJUUFOJO(P wIUUQTHJUIVCDPNL-P8UCMT w.BSLEPXO ('. ܗࣜͰσʔλϕʔευΩϡϝϯτΛੜ੒ͯ͘͠ΕΔ$-* πʔϧ w$*ϑϨϯυϦʔͳίϚϯυ΋͋Δʢޙड़ 

    
  16. Πϯετʔϧ w)PNFCSFXͰΠϯετʔϧՄೳ   $ go get -u github.com/k1LoW/tbls $

    brew install k1LoW/tbls/tbls w(P੡ͳͷͰHPHFUͰ΋ΠϯετʔϧͰ͖·͢
  17. Φϓγϣϯ(SBQIWJ[ͷΠϯετʔϧ w&3ਤੜ੒ͷͨΊͷ(SBQIWJ[ΛΠϯετʔϧ͠·͢   $ brew install graphviz

  18. AUCMTEPDAσʔλϕʔευΩϡϝϯτͷੜ੒ wAUCMTEPDAίϚϯυͰσʔλϕʔεʹ઀ଓͯ͠υΩϡϝϯτΛੜ੒͠·͢   $ tbls doc mysql://user:pass@hostname:3306/dbname ./dbdoc

  19. ͦͯ͠(JU)VCʹίϛοτ

  20. None
  21. 4".1-&

  22. .BSLEPXOͰ͋Δྑ͞ w(JU)VC্Ͱ͸ࣗಈͰϨϯμϦϯά͞ΕΔ wJNH΋؆୯ʹઃஔͰ͖Δ wϚʔΫμ΢ϯͳͷͰHJUEJ⒎Ͱࠩ෼͕Θ͔Γ΍͍͢ wεΩʔϚߋ৽಺༰͕Θ͔Γ΍͍͢

  23. lEJ⒎z

  24. AUCMTEJ⒎AυΩϡϝϯτͱσʔλϕʔεͷࠩ෼ wAUCMTEPDAΛAUCMTEJ⒎Aʹม͑Δ͚ͩͰσʔλϕʔεʹ઀ଓͯ͠طଘͷ ੜ੒ࡁΈυΩϡϝϯτͱͷࠩ෼Λग़ྗ͠·͢ʢ(SBQIWJ[Ͱग़ྗͨ͠&3ਤ Ҏ֎ʣ wࠩ෼͕ͳ͍ͱ͖͸Կ΋ग़ྗ͠ͳ͍   $ tbls diff

    mysql://user:pass@hostname:3306/dbname ./dbdoc
  25. lࠩ෼͕ͳ͍ͱ͖͸Կ΋ग़ྗ͠ͳ͍z

  26. ͜ͷ࢓૊ΈΛ࢖ͬͯ$*ʹ૊ΈࠐΉ

  27. $*࿈ܞ wσʔλϕʔεΛ࣋ͭΞϓϦέʔγϣϯͷςετʹ͸࠷৽ʹϚΠάϨʔγϣ ϯ͞Εͨσʔλϕʔε͕༻ҙ͞Ε͍ͯΔ͸ͣɻ wͦͷσʔλϕʔεʹ઀ଓͯ͠AUCMTEJ⒎AΛ࣮ߦɺίϛοτࡁΈͷυΩϡϝ ϯτͷࠩ෼Λ֬ೝɺࠩ෼͕͋Ε͹Τϥʔʹ͢Δɻ wUCMTίϚϯυ͸(P੡ͳͷͰϫϯόΠφϦɻͭ·Γ$*ʹ૊ΈࠐΈ΍͍͢  

  28. ྫ͑͹ϫϯϥΠφʔ w5SBWJT$*΍$JSDMF$*ͷ:".-ϑΝΠϧʹهड़ͯ͠ར༻Ͱ͖·͢   script: - DIFF=`tbls diff mysql://user:pass@hostname:3306/ dbname

    ./dbdoc` && if [ ! -z "$DIFF" ]; then echo "document does not match database." >&2 ; tbls diff mysql://user:pass@hostname:3306/dbname ./dbdoc; exit 1; fi
  29. ྫ͑͹.BLFpMF wANBLFEPDAͱANBLFUFTUEPDA   doc: ## Document database schema tbls

    doc mysql://user:pass@hostname:3306/dbname ./dbdoc testdoc: ## Test database schema document $(eval DIFF := $(shell tbls diff mysql:// user:pass@hostname:3306/dbname ./dbdoc)) @test -z "$(DIFF)" || (echo "document does not match database." && tbls diff mysql://user:pass@hostname:3306/ dbname ./dbdoc && exit 1)
  30. $*ϑϨϯυϦʔ

  31. ͞Βʹ

  32. AŠBEEAϦϨʔγϣϯɺίϝϯτͷิ׬ wUCMT͸',ΛΈͯϦϨʔγϣϯΛ൑ఆͯ͠&3ਤΛ࡞੒͢Δ w͔͠͠ɺੈͷதʹ͸',͕͸ͬͯͳ͍σʔλϕʔε΋͋ΔʢΩʔϨεΤϯ τϦʣ wӡ༻தͷσʔλϕʔεʹ$0..&/5ͷߋ৽ͷͨΊʹ"-5&3͸ͨ͘͠ͳ͍ wͦͷͨΊʹAŠBEEAΦϓγϣϯͰ:".-ϑΝΠϧΛࢦఆ͢Δ͜ͱͰϦϨʔ γϣϯɺίϝϯτͷิ׬͕Ͱ͖·͢  

  33. ίϚϯυͰυΩϡϝϯτੜ੒ ίϚϯυͰυΩϡϝϯτςετ

  34. .Z42- 1PTUHSF42-

  35. σʔλϕʔε υΩϡϝϯτ͕ͳ͍ υΩϡϝϯτ͕࠷৽Ͱͳ͍ ϓϩδΣΫτΛ ๾໓͢Δͧʂʂ

  36. 5IBOLZPV ࠷৽ͷ࠾༻৘ใΛνΣοΫˠ !QC@SFDSVJU