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
610
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.3k
Other Decks in Technology
See All in Technology
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
590
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
37
14k
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
200
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
350
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
750
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
110
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
190
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
190
なぜCodeceptJSを選んだか
goataka
0
160
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.3k
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
490
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
200
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Rails Girls Zürich Keynote
gr2m
94
13k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
For a Future-Friendly Web
brad_frost
175
9.4k
Typedesign – Prime Four
hannesfritz
40
2.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Six Lessons from altMBA
skipperchong
27
3.5k
Scaling GitHub
holman
458
140k
Side Projects
sachag
452
42k
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/
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ