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
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
いざ、BSC討伐の旅
nikinusu
2
780
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
Platform Engineering for Software Developers and Architects
syntasso
1
520
強いチームと開発生産性
onk
PRO
34
11k
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
Terraform Stacks入門 #HashiTalks
msato
0
350
Application Development WG Intro at AppDeveloperCon
salaboy
0
190
Featured
See All Featured
A Tale of Four Properties
chriscoyier
156
23k
Bash Introduction
62gerente
608
210k
Building Applications with DynamoDB
mza
90
6.1k
Practical Orchestrator
shlominoach
186
10k
Designing Experiences People Love
moore
138
23k
What's in a price? How to price your products and services
michaelherold
243
12k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
What's new in Ruby 2.0
geeforr
343
31k
A designer walks into a library…
pauljervisheath
204
24k
Ruby is Unlike a Banana
tanoku
97
11k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
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/
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ