Pro Yearly is on sale from $80 to $50! »

Ray.Di / Ray.Aop コトハジメ

Ray.Di / Ray.Aop コトハジメ

9541b31c963d9dc06901dab9d3049049?s=128

madapaja

July 19, 2012
Tweet

Transcript

  1. Ray.Di / Ray.Aop ίτϋδϝ BEAR.Sunday Meetup #0 2012/07/19 ؠ࡚ߊ࢘ @madapaja

  2. • ؠ࡚ߊ࢘ @madapaja • blog.madapaja.net • Symfony Ϣʔβʔձ • גࣜձࣾΤεɾΤϜɾΤε

    • հޢॅ୐ࣄۀ෦ • ΋͏͙͢ 0x1F ࡀ WHO AM I?
  3. AGENDA • BEAR.Sunday • Ray • Ray.Di • Ray.Aop

  4. BEAR.SUNDAY ʮϙΠϯτ͸໰୊ͷղܾʹ࣮૷Ͱ͸ͳ͘ઃܭͰ௅΋͏ͱͯ͠Δ఺Ͱ͢ɻ ͜Ε͕։ൃϦιʔεͷࡉ͍ࡉ͍๻͕௅ΊΔ།Ұͷํ๏Ͱ͢ɻʯ @koriym

  5. BEAR.SUNDAY KEYWORDS • PHP (5.4+) • Ϧιʔεࢦ޲ϑϨʔϜϫʔΫ / Because Everything

    is A Resource • ؔ৺ͷ෼཭ • REST • ίϚϯυΫΤϦ੹຿෼཭(CQRS) • APIۦಈ։ൃ • ΞεϖΫτࢦ޲ϓϩάϥϛϯά(AOP) • ґଘੑͷ஫ೖ(DI) • Cache • HATEOAS(Hypermedia as the Engine of Application State) • ...
  6. BEAR.SUNDAY 2ͭͷப • Ray • DI / AOP support •

    BEAR.Resource • Ϧιʔεࢦ޲ΞʔΩςΫνϟʢROAʣʹΑΔίϯ ϙʔωϯτ઀ଓͷͨΊͷαʔϏεϨΠϠϑϨʔϜϫʔ Ϋ
  7. RAY • Google Guice ͔ΒΠϯεύΠΞ • 2ͭͷύοέʔδ • Ray.Di •

    Ξϊςʔγϣϯϕʔεͷ Dependency Injection ϑϨʔϜϫʔΫ • ґଘੑͷ஫ೖΛ൐͏ΦϒδΣΫτͷੜ੒ͱ؅ཧ • Ray.Aop • ΞεϖΫτࢦ޲ϑϨʔϜϫʔΫ
  8. RAY.DI • based on Aura.Di • ΫϦʔϯ —— ίϯςφࣗ਎ͷґଘੑ΋શͯ֎෦஫ೖʹ಺෦Ͱ new

    ͞Ε͍ͯΔݻఆΫϥε͕ͳ ͘ೖΕସ͑Մೳ • ίϯετϥΫλ/ηολʔΠϯδΣΫγϣϯ • ܧঝ͕༗ޮͳωʔϜυύϥϝʔλࢦఆ • JSR-250(Common Annotations for Java)/330(DI for Java)ελΠϧΞϊςʔγϣϯͷҰ෦Λ ࣮૷ • Doctrine\Common\Annotations ʹΑΔΞϊςʔγϣϯ࣮૷ • Ray.AopʹΑΔΞεϖΫτΛ৫ΓࠐΜͩΦϒδΣΫτͷऔಘ
  9. HOW TO DI?

  10. HOW TO DI?

  11. HOW TO DI?

  12. SYMFONY DI COMPONENT

  13. SYMFONY DI COMPONENT Mailer ΫϥεͷҾ਺ʹ’sendmail’Λ஫ೖ

  14. SYMFONY DI COMPONENT Mailer ΫϥεͷҾ਺ʹ’sendmail’Λ஫ೖ NewsletterManager ΫϥεͷҾ਺ʹ MailerͷϦϑΝϨϯεΛ஫ೖ

  15. SYMFONY DI COMPONENT NewsletterManagerͷΠϯελϯεΛऔಘ Mailer ΫϥεͷҾ਺ʹ’sendmail’Λ஫ೖ NewsletterManager ΫϥεͷҾ਺ʹ MailerͷϦϑΝϨϯεΛ஫ೖ

  16. RAY.DI PATTERN A

  17. RAY.DI PATTERN A Mailer ΫϥεͷtransportҾ਺ʹ’sendmail’Λ஫ೖ

  18. RAY.DI PATTERN A Mailer ΫϥεͷtransportҾ਺ʹ’sendmail’Λ஫ೖ NewsletterManager ΫϥεͷmailerҾ਺ʹ Mailerͷ஗ԆΦϒδΣΫτੜ੒Λ஫ೖ

  19. RAY.DI PATTERN A NewsletterManagerͷΠϯελϯεΛऔಘ Mailer ΫϥεͷtransportҾ਺ʹ’sendmail’Λ஫ೖ NewsletterManager ΫϥεͷmailerҾ਺ʹ Mailerͷ஗ԆΦϒδΣΫτੜ੒Λ஫ೖ

  20. RAY.DI PATTERN A NewsletterManagerͷΠϯελϯεΛऔಘ Mailer ΫϥεͷtransportҾ਺ʹ’sendmail’Λ஫ೖ NewsletterManager ΫϥεͷmailerҾ਺ʹ Mailerͷ஗ԆΦϒδΣΫτੜ੒Λ஫ೖ ͜

    ͷ ํ ๏ ͸ Ξϊ ς ʔ γ ϣ ϯ Λ ߦ ͑ ͳ ͍ 3rdύʔ ςΟ /ط ଘ Φ ϒ δΣ Ϋ τ ͷ ͨ Ί ͷ ΋ ͷ
  21. RAY.DI PATTERN B ໊લ෇͖ΠϯδΣΫγϣϯࢦఆ ΠϯλʔϑΣʔεΠϯδΣΫγϣϯࢦఆ

  22. RAY.DI PATTERN B ໊લ෇͖ΠϯδΣΫγϣϯࢦఆ ΠϯλʔϑΣʔεΠϯδΣΫγϣϯࢦఆ

  23. RAY.DI PATTERN B ໊લ෇͖ΠϯδΣΫγϣϯࢦఆ ΠϯλʔϑΣʔεΠϯδΣΫγϣϯࢦఆ

  24. RAY.DI PATTERN B ϞδϡʔϧͰઃఆΛఆٛ ར༻

  25. RAY.DI PATTERN B ϞδϡʔϧͰઃఆΛఆٛ ར༻ Module::configure()ͰઃఆΛఆٛ

  26. RAY.DI PATTERN B ϞδϡʔϧͰઃఆΛఆٛ ར༻ Module::configure()ͰઃఆΛఆٛ transport_typeͱ͍͏໊લ෇͖ͷՕॴʹ ‘sendmail’ΛόΠϯυ

  27. RAY.DI PATTERN B ϞδϡʔϧͰઃఆΛఆٛ ར༻ Module::configure()ͰઃఆΛఆٛ transport_typeͱ͍͏໊લ෇͖ͷՕॴʹ ‘sendmail’ΛόΠϯυ MailerInterfaceͷ஫ೖ͕ඞཁͳՕॴʹ MailerΛόΠϯυ

  28. MODULE? • ಛఆͷؔ৺ྖҬʹ͍ͭͯͷઃఆ΍ߏ੒Λߦ͏୯Ґ ʢओʹDI΍ΠϯλʔηϓλͷͨΊͷόΠϯυΛߦ͏ʣ • ػೳͷؔ৺ʢDoctrineOrmModule/SwiftMailerModule...ʣ΍ ಈ࡞ϞʔυʢProdModule/DevModule...ʣͳͲͰ෼ׂ • Ϟδϡʔϧ͸ɺଞͷϞδϡʔϧΛ install

    Ͱؔ৺͝ͱʹ෼͚ΒΕͨϞδϡʔϧΛ߹੒Ͱ͖·͢ • ࠷ऴతʹ߹੒͞Εͨ஌ࣝʹΑͬͯΦϒδΣΫτάϥϑ͕ߏங͞Ε·͢ɻ • ϞδϡʔϧʹΑΓɺαʔϏείϯϙʔωϯτͦͷ΋ͷΛDIʹΑͬͯೖΕସ͑ɺ ͦͷৼΔ෣͍ΛAOPͰมߋ͢Δ ʢଟ͘ͷϑϨʔϜϫʔΫͱ͸ҟͳΓɺFWͰൃߦ͞ΕΔΠϕϯτ΍γάφϧʹରͯ͠ɺ ɹAppଆͰίʔϧόοΫΛΞλον͢ΔͷͰ͸͋Γ·ͤΜʣ
  29. RAY.DI OTHERS • @PostConstruct Ξϊςʔγϣϯ • શͯͷґଘ͕஫ೖࡁΈͷ͜ͱ͕อূ͞Εͨঢ়ଶͰͷॳظԽॲཧ • @PreDestory Ξϊςʔγϣϯ

    • શͯͷґଘΦϒδΣΫτ͕ഁյ͞Εͯͳ͍͜ͱ͕อো͞Εͨঢ়ଶͰͷγϟοτμ΢ϯॲཧ • @Scope • ΠϯελϯεͷৼΔ෣͍ઃఆʢγϯάϧτϯʣ • ηολʔΠϯδΣΫγϣϯ • traitΠϯδΣΫγϣϯ • ϓϩόΠμʔ • ...
  30. RAY.AOP • AOPΞϥΠΞϯε४ڌͷ ΞεϖΫτࢦ޲ϓϩάϥϛϯά࣮૷ • ԣஅతؔ৺ࣄʢΞεϖΫτʣͷॲཧ • ϝιουΠϯλʔηϓλ

  31. Πϯλʔηϓλ λΠϚʔ όϦσʔγϣϯ τϥϯβΫγϣϯ ࣮ϝιου

  32. ϝιουΠϯλʔηϓλͷఆٛ ϞδϡʔϧͰͷόΠϯυ ར༻

  33. ϝιουΠϯλʔηϓλͷఆٛ ϞδϡʔϧͰͷόΠϯυ ར༻ ࣮ϝιουͷݺͼग़͠

  34. ϝιουΠϯλʔηϓλͷఆٛ ϞδϡʔϧͰͷόΠϯυ ར༻ ࣮ϝιουͷݺͼग़͠ ͢΂ͯͷϝιουʹTimerInterceptorΛόΠϯυ

  35. ΠϯλʔηϓλͷRAY.AOP࣮૷

  36. OBJECT FRAMEWORK? • Ray.Di • ΦϒδΣΫτੜ੒ͷͨΊͷϑϨʔϜϫʔΫ • Ϟδϡʔϧ͕͍࣋ͬͯΔ஌ࣝΛར༻ͯ͠ɺDiͱΞεϖΫτΛߏ੒͠ɺΦϒδΣΫτάϥϑΛߏஙʢʹ ίϯύΠϧʣ •

    ૣظଋറͷߏ੒ʢܾ·ͬͯΔ΋ͷɺมߋ͕ͳ͍΋ͷʣ • Ray.Aop • ΦϒδΣΫτར༻ͷͨΊͷϑϨʔϜϫʔΫ • ϥϯλΠϜ • ஗Ԇଋറͷߏ੒ʢ࣮ߦ࣌ʹܾఆ͢ΔDBͷ઀ଓઌͳͲʣ͸ܾఆͨ࣌͠ʹόΠϯυ ʢϥϯλΠϜΠϯδΣΫλʣ
  37. OBJECT FRAMEWORK? • ੜ੒ͱར༻ͷ෼཭ • RayʢBEARʣͰ͸ੜ੒ͱར༻͕෼཭͞Ε͍ͯΔ • ੜ੒ͱར༻Λಉ࣌ʹߦΘͳ͍ • ੜ੒ͷ࠶ར༻͕Մೳ

    • ଞͷϑϨʔϜϫʔΫͱҰઢΛը͢ϨϕϧͰΩϟογϡΛߦ͑Δ • PHPɺΞϊςʔγϣϯͷύʔεɺΠϯδΣΫγϣϯͷίετ͕ݪཧతʹ0ʹͳΔ • Ray = ΦϒδΣΫτͷʮੜ੒ɺར༻ɺফ໓ʯΛ໘౗ΈΔΦϒδΣΫτϑϨʔϜϫʔΫ
  38. ·ͱΊ • BEAR.Sunday Λ৮ͬͯΈΑ͏ • Ray.Di / Ray.Aop / BEAR.Resource

    ͋ͨΓ͔Β࢝ΊΔͷ͕Φεεϝ • Ray.Aop Λ΍ͬͯΈΔ৔߹͸Ray.DiΛ௨ͯ͠৮Δͷָ͕ • Ray ʹؔͯ͠͸ɺϒϩάʢhttp://blog.madapaja.net/ʣʹ΋ ॻ͍ͨͷͰɺࢀߟʹͳΔ͔΋ʁ • Have fun!
  39. ࢀߟ • BEAR.Sunday Manual: http://code.google.com/p/bearsunday/wiki/manual?tm=6 • Ray PHP User Guide:

    http://code.google.com/p/rayphp/wiki/Motivation?tm=6 • BEAR.Sunday github: https://github.com/koriym/BEAR.Sunday • BEAR Blog: http://www.bear-project.net/blog/ • ܊ࢁ͞Μ Slideshare: http://www.slideshare.net/akihito.koriyama/
  40. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ