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

闇より生まれし混沌の魔王を封印するために〜クロスリファレンスによるカオスなSymfonyプロジェクトをこれ以上作らない活動・実践報告〜

 闇より生まれし混沌の魔王を封印するために〜クロスリファレンスによるカオスなSymfonyプロジェクトをこれ以上作らない活動・実践報告〜

Symfony Meetup Kansai Online 3にて発表

B793da271a45d149b52f507bca9f137c?s=128

Hiromi Hishida

April 04, 2020
Tweet

Transcript

  1. UI"QSJM 4ZNGPOZ.FFUVQ,BOTBJ 0OMJOF CZ!XFC ҋΑΓੜ·Εࠞ͠ಱͷຐԦΛ෧ҹ ͠Α͏ ʙΫϩεϦϑΝϨϯεʹΑΔΧΦεͳ4ZNGPOZϓϩδΣΫτΛ͜Ε Ҏ্࡞Βͳ͍׆ಈɾ࣮ફใࠂʙ

  2. ɾ!XFC ɾϑϦʔϥϯεʢ೥͙Β͍ʣˠΧϧςοτίϛϡχέʔγϣϯζʢ೥ʣ ɾ໊ݹ԰ ɾࣇͷ฼ ɾ೔ຊ4ZNGPOZϢʔβʔձ ɾ*—1)1

  3. ɾӡ༻ܕ޿ࠂۀքΛϗϫΠτʹ͢Δ࢓૊ΈΛ࡞ͬͯ·͢ ɾ஥ؒืूதʂʢϑϧϦϞʔτɺύʔτλΠϜɺ΋ͪΖΜϑϧ λΠϜਖ਼ࣾһ΋׻ܴʣ ɾ4ZNGPOZ࢖ͬͯ·͢ʂ

  4. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ

  5. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ w 4ZNGPOZ͙Β͍Ͱ࡞Γ࢝Ίͯ4ZNGPOZ·ͰΞοϓσʔτ͖ͯͨ͠ϓϩ δΣΫτ w ͨ͘͞Μͷπʔϧ͕͋Δ w ֤πʔϧ͸#VOEMFͱͯ͠։ൃ͞Ε͍ͯΔ͕ɺجຊతʹͭͷHJUϨϙδτϦʹ શπʔϧͷόϯυϧ͕ฒΜͰ͍Δʢ4ZNGPOZ࣌୅ͷޙ൒ͷ"QQ#VOEMF୯Ұ ओٛ΍4ZNGPOZ

    ͰͷTSD"QQʹશͯΛஔ͘ελΠϧͱ͸ҟͳΔʣ
  6. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ Ͳ͏͍͏͜ͱ͕ى͖Δ͔ʁ w ػೳ"ɾػೳ#͕ͦͷ··"BB#VOEMF #CC#VOEMFʹͳ͍ͬͯΔ

  7. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ Ͳ͏͍͏͜ͱ͕ى͖Δ͔ʁ w ػೳ"ɾػೳ#͕ͦͷ··"BB#VOEMF #CC#VOEMFʹͳ͍ͬͯΔ w ػೳ$Λ࡞Δ͜ͱʹͳͬͨɻػೳ$ͷΤϯςΟςΟ͸ػೳ"ͷΤϯςΟςΟʹ ؔ࿈͍͍ͮͯͯɺػೳ#͕͍࣋ͬͯΔॲཧ΋࢖͍·Θ͍ͨ͠ͳʔ

  8. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ Ͳ͏͍͏͜ͱ͕ى͖Δ͔ʁ w ػೳ"ɾػೳ#͕ͦͷ··"BB#VOEMF #CC#VOEMFʹͳ͍ͬͯΔ w ػೳ$Λ࡞Δ͜ͱʹͳͬͨɻػೳ$ͷΤϯςΟςΟ͸ػೳ"ͷΤϯςΟςΟʹ ؔ࿈͍͍ͮͯͯɺػೳ#͕͍࣋ͬͯΔΫϥε΋࢖͍·Θ͍ͨ͠ͳʔ w $DD#VOEMFͷΫϥε͕"BB#VOEMF

    #CC#VOEMFͷΫϥεʹґଘ͢Δ w VTF.Z"QQa#VOEMFa"BB#VOEMFa&OUJUZa'PP#BS w VTF.Z"QQa#VOEMFa#CC#VOEMFa)PHF)PHF
  9. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ Ͳ͏͍͏͜ͱ͕ى͖Δ͔ʁ w ࠓ౓͸ػೳ#ͷػೳ௥Ճ͕ൃੜͯ͠ɺػೳ$ʹ͋ΔΫϥεΛ࢖͍ͨ͘ͳͬͨ

  10. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ Ͳ͏͍͏͜ͱ͕ى͖Δ͔ʁ w ࠓ౓͸ػೳ#ͷػೳ௥Ճ͕ൃੜͯ͠ɺػೳ$ʹ͋ΔΫϥεΛ࢖͍ͨ͘ͳͬͨ ΧΦεͷ༧ײʂ

  11. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ ΫϩεϦϑΝϨϯε஍ࠈ w ػೳ" ػೳ#Λվम͢Δͱػೳ$ʹ೾ٴ͢Δ w ػೳ$Λվम͢Δͱػೳ#ʹ΋೾ٴ͢Δ

  12. ҋΑΓੜ·Εࠞ͠ಱͷຐԦ ΫϩεϦϑΝϨϯε஍ࠈ w ػೳ" ػೳ#Λվम͢Δͱػೳ$ʹ೾ٴ͢Δ w ػೳ$Λվम͢Δͱػೳ#ʹ΋೾ٴ͢Δ ׬શͳΔΧΦε

  13. ΫϩεϦϑΝϨϯεͰࠔͬͯΔΜ͢Αʙͱݴ͏ͱ͍͚ͨͩΔ͋Γ͕ͪͳΞυόΠε ίϯςΫετڥքΛීஈ͔ΒͪΌΜͱҙࣝ͠ ͯʙ ґଘͷํ޲Λීஈ͔ΒͪΌΜͱҙࣝͯ͠ʙ

  14. ΫϩεϦϑΝϨϯεͰࠔͬͯΔΜ͢Αʙͱݴ͏ͱ͍͚ͨͩΔ͋Γ͕ͪͳΞυόΠε ίϯςΫετڥքΛීஈ͔ΒͪΌΜͱҙࣝ͠ ͯʙ ґଘͷํ޲Λීஈ͔ΒͪΌΜͱҙࣝͯ͠ʙ ਓྨʹ͸ແཧ

  15. ΫϩεϦϑΝϨϯεΛ๷͙ʹ͸ɺڥք͝ͱʹ༧ ΊϨϙδτϦΛ෼͚Ε͹ྑ͍ɻߥྍ࣏͚ͩͲ ઈରʹΫϩεϦϑΝϨϯεͰ͖ͳ͍ʢ෺ཧʣɻ

  16. ࠞಱΛ෧ҹ͢ΔͨΊͷߥྍ࣏

  17. ࠞಱΛ෧ҹ͢ΔͨΊͷߥྍ࣏ ϧʔϧ w "BB#VOEMF #CC#VOEMF $DD#VOEMF͸͢΂ͯผͷHJUϨϙδτϦʹஔ͘ w 4ZNGPOZίϯϙʔωϯτ͕ͦΕͧΕಠཱͨ͠HJUϨϙδτϦʹஔ͔Ε͍ͯͯ TZNGPOZTZNGPOZશ෦ΛಡΈࠐ·ͳͯ͘΋ඞཁͳίϯϙʔωϯτʢTZNGPOZ ZBNMͱ͔ʣ͚ͩSFRVJSFͯ͠࢖͑ΔΠϝʔδ

    ˞ຊՈ4ZNGPOZ͸TZNGPOZTZNGPOZͱ͍͏ϞϊϦεͰ։ൃͨ͠΋ͷΛTQMJUTIͱ ͍͏εΫϦϓτΛ࢖ͬͯݸผͷίϯϙʔωϯτʹ෼͚ΒΕ͍ͯΔͷͰݫີʹ͸ҧ ͍·͢ w ͨͩ͠ɺ"BB#VOEMF #CC#VOEMF $DD#VOEMF͸૬ޓʹDPNQPTFSSFRVJSF ېࢭ
  18. ࠞಱΛ෧ҹ͢ΔͨΊͷߥྍ࣏ ࣮ࡍʹ࢖ͬͨςΫχοΫ঺հ  ΞϓϦέʔγϣϯͱόϯυϧΛ෼཭ w ػೳ"ɾػೳ#ɾػೳ$Λඋ͑ͨ8FCΞϓϦέʔγϣϯͱͯ͠Ϣʔβʔʹఏڙ ͢ΔͨΊʹ͸ɺ"BB#VOEMF #CC#VOEMF $DD#VOEMFΛ͢΂ͯDPNQPTFS SFRVJSFͯ͠౷߹͢Δ4ZNGPOZΞϓϦέʔγϣϯ͸ඞཁ

    w Ϣʔβʔొ࿥ɾϩάΠϯɾϩάΞ΢τɾ՝ۚʜͱ͍ͬͨ8FCαʔϏεͱͯ͠ ͷৼΔ෣͍͸4ZNGPOZΞϓϦέʔγϣϯଆ͕࣋ͭ w "BB#VOEMF #CC#VOEMF $DD#VOEMF͸8FCαʔϏεͱͯ͠ͷৼΔ෣͍ʹ͸ ؔ৺Λ࣋ͨͣɺ֤πʔϧͷػೳ͚ͩΛ࣋ͭ
  19. ࠞಱΛ෧ҹ͢ΔͨΊͷߥྍ࣏ ࣮ࡍʹ࢖ͬͨςΫχοΫ঺հ  JOUFSGBDF w ػೳ"ʹ͸ΞϓϦέʔγϣϯͷ6TFS͕ॴ༗͢Δ"BB3FTPVSDFͱ͍͏ΤϯςΟςΟ͕ ඞཁ w "BB#VOEMF͸ΞϓϦέʔγϣϯͷ6TFSʹ͸ґଘͰ͖ͳ͍ w

    "BB#VOEMF͸6TFSΛ࣋ͭ4ZNGPOZΞϓϦέʔγϣϯΛDPNQPTFSSFRVJSFͯ͠ͳ ͍ w ٯʹ4ZNGPOZΞϓϦέʔγϣϯͷଆ͸"BB#VOEMFΛDPNQPTFSSFRVJSF͍ͯ͠Δ w "BB#VOEMFʹ"BB3FTPVSDF0XOFS*OUFSGBDFΛఆٛ͠ɺ4ZNGPOZΞϓϦέʔγϣϯ ͷ6TFS͸"BB3FTPVSDF0XOFS*OUFSGBDFΛJNQMFNFOUTͨ͠
  20. ࠞಱΛ෧ҹ͢ΔͨΊͷߥྍ࣏ ࣮ࡍʹ࢖ͬͨςΫχοΫ঺հ  $POUSBDU w "BB#VOEMFͷΤϯςΟςΟʹ$DD#VOEMFͷΤϯςΟςΟ͕ґଘ͍͚ͨ͠Ͳ $DD#VOEMF͸ΞϓϦଆʹґଘʢDPNQPTFSSFRVJSFʣͰ͖ͳ͍ w "BB#VOEMF $DD#VOEMFύοέʔδͱ͸ผʹ$POUSBDUύοέʔδΛ࡞Δ

    w $POUSBDUύοέʔδ͸JOUFSGBDF͚ͩΛ࣋ͭ w "BB#VOEMF $DD#VOEMF͸$POUSBDUύοέʔδΛDPNQPTFSSFRVJSFͯ͠ྑ ͍
  21. ࠞಱΛ෧ҹ͢ΔͨΊͷߥྍ࣏ ࣮ࡍʹ࢖ͬͨςΫχοΫ঺հ  3FTPMWF5BSHFU&OUJUZ w $POUSBDU΍#VOEMFଆͷJOUFSGBDFΛ࣮ࡍʹΤϯςΟςΟͱͯ͠࢖͏ͨΊʹɺ %PDUSJOF ͷػೳz3FTPMWF5BSHFU&OUJUZzΛ࢖͏ https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/resolve-target- entity-listener.html

  22. ࠞಱΛ෧ҹ͢ΔͨΊͷߥྍ࣏ ࣮ࡍʹ࢖ͬͨςΫχοΫ঺հ  3FTPMWF5BSHFU&OUJUZ

  23. ߥྍ࣏Λ࢝Ί࣮ͯࡍʹى͖ͨ͜ͱ

  24. ࣮ࡍʹى͖ͨ͜ͱ ʢʣґଘؔ܎ͷ൓స w ϞϊϦε࣌୅͸"BB#VOEMFa&OUJUZa"BB3FTPVSDF͕ "QQ#VOEMFa&OUJUZa6TFSΛVTF͍ͯͨ͠ w ࠓ౓͸"QQa&OUJUZa6TFS͕ "BB#VOEMFa&OUJUZa"BB3FTPVSDF0XOFS*OUFSGBDFΛJNQMFNFOUT͍ͯ͠Δ

  25. ࣮ࡍʹى͖ͨ͜ͱ ʢʣ8FCΞϓϦέʔγϣϯͱͯ͠ͷຊ࣭͕ଊ͑΍͘͢ͳͬͨ w 6TFSͷ࣋ͭ৘ใͷ͏ͪɺػೳ"ͷཁ੥Ͱ͍࣋ͬͯΔ৘ใ ʢ"BB3FTPVSDF0XOFS*OUFSGBDFͷϝιουʹରԠ߲ͨ͠໨ʣͱ8FCΞϓϦ έʔγϣϯͷձһͱͯ͠ඞཁͳ৘ใʢ"QQଆ͚ͩͰఆٛ͞Ε͍ͯΔ߲໨ʣ͕ ෼͚ͯଊ͑Δ͜ͱ͕Ͱ͖Δ w 8FCΞϓϦέʔγϣϯͱͯ͠ຊ౰ʹඞཁͳػೳʢຊ࣭ʣ͸Կͳͷ͔ݟ͑΍ ͍͢

  26. ࣮ࡍʹى͖ͨ͜ͱ ʢʣ4ZNGPOZͷ%FQFOEFODZ*OKFDUJPOίϯϙʔωϯτʹৄ͘͠ͳͬͨ w 3FTPVSDFTDPOpHTFSWJDFTZNMͷ͜ͱͰ͸ͳ͘"BB#VOEMF%FQFOEFODZ*OKFDUJPOʹ͋Δ ΫϥεͷதΛΰϦΰϦॻ͔͘Ͳ͏͔ͷ࿩ w 4ZNGPOZ࣌୅ʹόϯυϧελΠϧͰ։ൃ͍ͯͯ͠΋ΰϦΰϦॻ͍ͯͨਓ͸গͳ͍ʢͱࢥ͏ʣ w ͍͍ͤͥUBHΛ࡞ͬͯ$PNQJMFS1BTTͰҰׅॲཧͨ͠Γɺෳ਺ϑΝΠϧʹ෼ׂͨ͠αʔϏε ఆٛZNMΛಡΈࠐΜ͙ͩΒ͍ʁ

    w "BB#VOEMF͸3FTPVSDFTDPOpHTFSWJDFTZNMͰ8FCΞϓϦέʔγϣϯଆͷFOW΍ QBSBNFUFSΛ௚઀ࢀরͰ͖ͳ͍ͷͰɺ"BB#VOEMFa%FQFOEFODZ*OKFDUJPOa$POpHVSBUJPOͱ "BB#VOEMFa%FQFOEFODZ*OKFDUJPOa"BB&YUFOTJPOΛ࢖ͬͯFOW΍QBSBNFUFSΛऔΓࠐΉඞཁ ͕͋Δ
  27. ࣮ࡍʹى͖ͨ͜ͱ ʢʣ4ZNGPOZͷ%FQFOEFODZ*OKFDUJPOίϯϙʔωϯτʹৄ͘͠ͳͬͨ ϞβΠΫ෦෼͸αʔυύʔςΟόϯυϧ Ͱͳࣗ͘લόϯυϧͷઃఆZNM

  28. ࣮ࡍʹى͖ͨ͜ͱ ʢʣ$*͕͍ܰʂϩʔΧϧͰͷςετ࣮ߦ΋଎͍ʂ w ϞϊϦε࣌୅͸ΞϓϦέʔγϣϯશମͷςετΛ૸ΒͤΔͱ෼Ҏ্͔͔ Γɺ$*ͰύϥϨϧ࣮ߦͯ͠΋෼͔͔͍ۙͬͯͨ͘ w "BB#VOEMF #CC#VOEMF $DD#VOEMFͦΕͧΕ୯ମͰςετ͢Δͱɺ෼ະ ຬɻ౷߹ͨ͠ΞϓϦέʔγϣϯࣗମͷςετ΋෼͠ͳ͍ͰऴΘΔɻʢ͍ͣΕ

    ΋%#Λ࢖ͬͨػೳςετΛؚΉʣ w ։ൃऀ͕ͱͯ΋IBQQZ
  29. ࣮ࡍʹى͖ͨ͜ͱ ʢʣ෼୲͠΍͍͢ w ϞϊϦε࣌୅͸ؾΛ͚ͭͯΞαΠϯͯ͠΋ίϯϑϦΫτ͕ൃੜ͕ͪͩͬͨ͠ w ػೳ$ͷվम࣌ʹػೳ" ػೳ#ͷΫϥε΋৮ͬͪΌ͏ɾ৮Β͟ΔΛಘͳ͍έʔ ε͕ଟൃ͍ͯͨ͠ w ։ൃऀ9ʹ"BB#VOEMFɺ։ൃऀ:ʹ#CC#VOEMFΛΞαΠϯͨ͠Βશ͘ίϯϑϦ

    Ϋτ͠ͳ͍ w ͱ͸͍͑ɺ΋ͱ΋ͱਓ਺গͳ͍ˍ৭ʑ݉຿Ͱճͯ͠ΔͷͰϚδʹ஥ؒืूͰ͢ʂ ؾʹͳͬͨਓ͸ࢲ͔!TNEIPHFIPHF͔!LJONB@Oʹ੠͔͚͍ͯͩ͘͞ʂ
  30. ՝୊

  31. ՝୊ w ࣗࣾαʔϏεͳͷͰɺ։ൃ׬ྃͨ͠ޙʹ௕͍อकظ͕ؒ͋Δ w ͦͷؒͣͬͱϧʔϧΛकΓଓ͚ΒΕΔ͔Ͳ͏͔ʁ

  32. ՝୊ w ౷߹͞Εͨ4ZNGPOZΞϓϦέʔγϣϯ͸"BB#VOEMF #CC#VOEMF  $DD#VOEMFશͯͷΫϥεʹґଘͰ͖Δ w ͪΌΜͱؾΛ͚ͭͳ͍ͱ౷߹ΞϓϦέʔγϣϯ಺ͰΫϩεϦϑΝϨϯε͕ى ͖͏Δ w

    ٯʹɺ౷߹ΞϓϦέʔγϣϯϨΠϠʔ͚ͩ৻ॏʹॻ͚͹ݸผͷόϯυϧ಺ Ͱ͸ΫϩεϦϑΝϨϯε͸৺഑͠ͳͯ͘ྑ͍ͱ΋ݴ͑Δ͕ʜɻॻ͘ͷ͸ਓؒ ͳͷͰɻ
  33. ·ͱΊ

  34. w Χϧςοτ։ൃ෦ͷ௅ઓ͸࢝·ͬͨ͹͔Γ w ੒ޭ͢Δ͔ɺരࢮ͢Δ͔·ͩΘ͔Βͳ͍ ·ͱΊ

  35. 5IBOLZPVBOEUPCFDPOUJOVFEʜ