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
Ray.Di-Ray.AopからみるPHP5.4+フレームワークBEAR.Sunday
Search
madapaja
July 30, 2012
Technology
3
600
Ray.Di-Ray.AopからみるPHP5.4+フレームワークBEAR.Sunday
madapaja
July 30, 2012
Tweet
Share
More Decks by madapaja
See All by madapaja
JS/jQueryのはなし | リジョブ社内勉強会
madapaja
0
290
BEAR.Sunday のはなし - 第89回PHP勉強会@東京
madapaja
3
2.1k
Ray.Di / Ray.Aop コトハジメ
madapaja
3
2.2k
Other Decks in Technology
See All in Technology
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
160
心が動くエンジニアリング ── 私が夢中になる理由
16bitidol
0
100
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
Lexical Analysis
shigashiyama
1
150
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
310
アプリエンジニアのためのGraphQL入門.pdf
spycwolf
0
100
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
260
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
4 Signs Your Business is Dying
shpigford
180
21k
Teambox: Starting and Learning
jrom
133
8.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Unsuck your backbone
ammeep
668
57k
Six Lessons from altMBA
skipperchong
27
3.5k
Transcript
Ray.Di/Ray.Aop ͔ΒΈΔ PHP5.4+ϑϨʔϜϫʔΫBEAR.Sunday ୈ61ճPHPษڧձ@౦ژ 2012/07/30 ؠ࡚ߊ࢘ @madapaja
Ray.Di/Ray.Aop ͔ΒΈΔ PHP5.4+ϑϨʔϜϫʔΫBEAR.Sunday ୈ61ճPHPษڧձ@౦ژ 2012/07/30 ؠ࡚ߊ࢘ @madapaja
• ؠ࡚ߊ࢘ @madapaja • blog.madapaja.net • Symfony Ϣʔβʔձ • גࣜձࣾΤεɾΤϜɾΤε
• հޢॅࣄۀ෦ • ͏͙͢ 0x1F ࡀ WHO AM I?
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) • ...
AGENDA • BEAR.Sunday • Ray • DI • Ray.Di
BEAR.SUNDAY 2ͭͷப • Ray • DI / AOP support •
BEAR.Resource • ϦιʔεࢦΞʔΩςΫνϟʢROAʣʹΑΔίϯϙ ʔωϯτଓͷͨΊͷαʔϏεϨΠϠϑϨʔϜϫʔ Ϋ
RAY • Google Guice ͔ΒΠϯεύΠΞ • 2ͭͷύοέʔδ • Ray.Di •
Ξϊςʔγϣϯϕʔεͷ Dependency Injection ϑϨʔϜϫʔΫ • ґଘੑͷೖΛ͏ΦϒδΣΫτͷੜͱཧ • Ray.Aop • ΞεϖΫτࢦϑϨʔϜϫʔΫ
DI? • Dependency Injection / ґଘੑͷೖ • ίϯϙʔωϯτʢΫϥεʣؒͷؔੑΛૄʹ͠ɺར༻ ͢ΔαʔϏεͷ࣮ґଘΛऔΓআ͜͏ͱ͢Δٕज़
DI? • Dependency Injection / ґଘੑͷೖ • ίϯϙʔωϯτʢΫϥεʣؒͷؔੑΛૄʹ͠ɺར༻ ͢ΔαʔϏεͷ࣮ґଘΛऔΓআ͜͏ͱ͢Δٕज़ ͳͥʁ
૾ͯ͠ΈΑ͏
૾ͯ͠ΈΑ͏ ϑΝΠϧʹ͍ͨ࣌͠ʁ
૾ͯ͠ΈΑ͏ ϑΝΠϧʹ͍ͨ࣌͠ʁ MongoDBΛ͍͍ͨͱ͖ʁ
૾ͯ͠ΈΑ͏
૾ͯ͠ΈΑ͏
૾ͯ͠ΈΑ͏
૾ͯ͠ΈΑ͏ มߋ͕͍͠
૾ͯ͠ΈΑ͏ มߋ͕͍͠ WikiModel Λܧঝͯ͠ MongoWikiModel Λ࡞Δʁ
૾ͯ͠ΈΑ͏ มߋ͕͍͠ WikiModel Λܧঝͯ͠ MongoWikiModel Λ࡞Δʁ ͳΜ͔ɺͦΕ͓͔͘͠ͳ͍ʁ
վળͯ͠ΈΔ
վળͯ͠ΈΔ ΠϯλʔϑΣʔεΛ༻ҙ
վળͯ͠ΈΔ ΠϯλʔϑΣʔεΛ༻ҙ ΠϯλʔϑΣʔεͷ࣮Λ༻ҙ
վળͯ͠ΈΔ
վળͯ͠ΈΔ
վળͯ͠ΈΔ ΠϯλʔϑΣʔεͷΈʹґଘ
վળͯ͠ΈΔ ΠϯλʔϑΣʔεͷΈʹґଘ
վળͯ͠ΈΔ ΠϯλʔϑΣʔεͷΈʹґଘ มߋ͕༰қʹ ͨͩ͠ɺར༻গ͠໘ʹ
ґଘੑͷೖ
ґଘੑͷೖ
ґଘੑͷೖ ґଘ
ґଘੑͷೖ ґଘ
ґଘੑͷೖ ґଘ ೖ
ετϨʔδΛมߋͯ͠ΈΔ ϑΝΠϧͷར༻ MongoDBͷར༻
ετϨʔδΛมߋͯ͠ΈΔ ϑΝΠϧͷར༻ MongoDBͷར༻ Ͳ ͪ Β WikiModel ม
ߋ ͕ ͳ ͍
Ҏ্͕DIͷҰൠతͳઆ໌Ͱ͢ 1/2ɹ࣌ؒ֬ೝʂ
HOW TO DI?
HOW TO DI?
HOW TO DI?
SYMFONY DI COMPONENT
SYMFONY DI COMPONENT Mailer ΫϥεͷҾʹ’sendmail’Λೖ
SYMFONY DI COMPONENT Mailer ΫϥεͷҾʹ’sendmail’Λೖ NewsletterManager ΫϥεͷҾʹ MailerͷϦϑΝϨϯεΛೖ
SYMFONY DI COMPONENT NewsletterManagerͷΠϯελϯεΛऔಘ Mailer ΫϥεͷҾʹ’sendmail’Λೖ NewsletterManager ΫϥεͷҾʹ MailerͷϦϑΝϨϯεΛೖ
DIP? • Dependency Inversion Principle / ґଘؔٯసͷݪଇ • ࣮ʹґଘͤͣɺநʹґଘ͢Δ •
ϓϩάϥϜ۩ମతͳΫϥεʹґଘ͍͚ͯ͠ͳ͍ • நͱ࣮ͷৄࡉ͕શʹΓ͞ΕΔʢϝϯςָ͕ ʹʣ
SYMFONY DI COMPONENT ͏ҰݟͯΈΑ͏
SYMFONY DI COMPONENT Mailer ΫϥεͷίϯετϥΫλҾʹ’sendmail‘͕͋Δ͜ͱ ͏ҰݟͯΈΑ͏
SYMFONY DI COMPONENT Mailer ΫϥεͷίϯετϥΫλҾʹ’sendmail‘͕͋Δ͜ͱ NewsletterManager ΫϥεͷҾʹ Mailer͕͋Δ͜ͱ ͏ҰݟͯΈΑ͏
SYMFONY DI COMPONENT Mailer ΫϥεͷίϯετϥΫλҾʹ’sendmail‘͕͋Δ͜ͱ NewsletterManager ΫϥεͷҾʹ Mailer͕͋Δ͜ͱ ͏ҰݟͯΈΑ͏ ར༻ଆ͕͍ͬͯΔʂʁʹ࣮ʹґଘ͍ͯ͠Δ
SYMFONY DI COMPONENT Mailer ΫϥεͷίϯετϥΫλҾʹ’sendmail‘͕͋Δ͜ͱ NewsletterManager ΫϥεͷҾʹ Mailer͕͋Δ͜ͱ ͏ҰݟͯΈΑ͏ ར༻ଆ͕͍ͬͯΔʂʁʹ࣮ʹґଘ͍ͯ͠Δ
Α Γ ྑ ͍ Γ ํ ʁ
RAY.DI ໊લ͖ΠϯδΣΫγϣϯࢦఆ ΠϯλʔϑΣʔεΠϯδΣΫγϣϯࢦఆ
RAY.DI ໊લ͖ΠϯδΣΫγϣϯࢦఆ ΠϯλʔϑΣʔεΠϯδΣΫγϣϯࢦఆ
RAY.DI ໊લ͖ΠϯδΣΫγϣϯࢦఆ ΠϯλʔϑΣʔεΠϯδΣΫγϣϯࢦఆ
RAY.DI ϞδϡʔϧͰઃఆΛఆٛ ར༻
RAY.DI ϞδϡʔϧͰઃఆΛఆٛ ར༻ Module::configure()ͰઃఆΛఆٛ
RAY.DI ϞδϡʔϧͰઃఆΛఆٛ ར༻ Module::configure()ͰઃఆΛఆٛ transport_typeͱ͍͏໊લ͖ͷՕॴʹ ‘sendmail’ΛόΠϯυ
RAY.DI ϞδϡʔϧͰઃఆΛఆٛ ར༻ Module::configure()ͰઃఆΛఆٛ transport_typeͱ͍͏໊લ͖ͷՕॴʹ ‘sendmail’ΛόΠϯυ MailerInterfaceͷೖ͕ඞཁͳՕॴʹ MailerΛόΠϯυ
RAY.DI ϞδϡʔϧͰઃఆΛఆٛ ར༻ Module::configure()ͰઃఆΛఆٛ transport_typeͱ͍͏໊લ͖ͷՕॴʹ ‘sendmail’ΛόΠϯυ MailerInterfaceͷೖ͕ඞཁͳՕॴʹ MailerΛόΠϯυ ΠϯλʔϑΣʔεʹରͯ͠Ͳͷ࣮Λར༻͢Δ͔ɺͷΈఆٛ ೖ͕ඞཁͳ෦ʹɺউखʹೖͯ͘͠ΕΔ
ͲΜͳ࣮͔Λҙࣝ͠ͳ͍Ͱར༻Ͱ͖Δ
RAY.DI • based on Aura.Di • ΫϦʔϯ —— ίϯςφࣗͷґଘੑશͯ֎෦ೖʹ෦Ͱ new
͞Ε͍ͯΔݻఆΫϥε͕ͳ ͘ೖΕସ͑Մೳ • ίϯετϥΫλ/ηολʔΠϯδΣΫγϣϯ • ܧঝ͕༗ޮͳωʔϜυύϥϝʔλࢦఆ • JSR-250(Common Annotations for Java)/330(DI for Java)ελΠϧΞϊςʔγϣϯͷҰ෦Λ ࣮ • Doctrine\Common\Annotations ʹΑΔΞϊςʔγϣϯ࣮ • Ray.AopʹΑΔΞεϖΫτΛ৫ΓࠐΜͩΦϒδΣΫτͷऔಘ
OBJECT GRAPH
OBJECT FRAMEWORK? • Ray.Di • ΦϒδΣΫτੜͷͨΊͷϑϨʔϜϫʔΫ • Ϟδϡʔϧ͕͍࣋ͬͯΔࣝΛར༻ͯ͠ɺDiͱΞεϖΫτΛߏ͠ɺΦϒδΣΫτάϥϑΛߏஙʢʹ ίϯύΠϧʣ •
ૣظଋറͷߏʢܾ·ͬͯΔͷɺมߋ͕ͳ͍ͷʣ • Ray.Aop • ΦϒδΣΫτར༻ͷͨΊͷϑϨʔϜϫʔΫ • ϥϯλΠϜ • Ԇଋറͷߏʢ࣮ߦ࣌ʹܾఆ͢ΔDBͷଓઌͳͲʣܾఆͨ࣌͠ʹόΠϯυ ʢϥϯλΠϜΠϯδΣΫλʣ
OBJECT FRAMEWORK? • ੜͱར༻ͷ • RayʢBEARʣͰੜͱར༻͕͞Ε͍ͯΔ • ੜͱར༻Λಉ࣌ʹߦΘͳ͍ • ੜͷ࠶ར༻͕Մೳ
• ଞͷϑϨʔϜϫʔΫͱҰઢΛը͢ϨϕϧͰΩϟογϡΛߦ͑Δ • PHPɺΞϊςʔγϣϯͷύʔεɺΠϯδΣΫγϣϯͷίετ͕ݪཧతʹ0ʹͳΔ • Ray = ΦϒδΣΫτͷʮੜɺར༻ɺফ໓ʯΛ໘ΈΔΦϒδΣΫτϑϨʔϜϫʔΫ
·ͱΊ • BEAR.Sunday Λ৮ͬͯΈΑ͏ • Ray.Di / Ray.Aop / BEAR.Resource
͋ͨΓ͔Β࢝ΊΔͷ͕Φεεϝ • Ray.Aop ΛͬͯΈΔ߹Ray.DiΛ௨ͯ͠৮Δͷָ͕ • Ray ʹؔͯ͠ɺϒϩάʢhttp://blog.madapaja.net/ʣʹ ॻ͍ͨͷͰɺࢀߟʹͳΔ͔ʁ • Have fun!
ࢀߟ • 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/
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ