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
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
480
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
210
どちらを使う?GitHub or Azure DevOps Ver. 24H2
kkamegawa
0
720
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
260
20241220_S3 tablesの使い方を検証してみた
handy
3
380
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
280
.NET 9 のパフォーマンス改善
nenonaninu
0
850
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
110
5分でわかるDuckDB
chanyou0311
10
3.2k
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Agile that works and the tools we love
rasmusluckow
328
21k
Writing Fast Ruby
sferik
628
61k
Designing for Performance
lara
604
68k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
How STYLIGHT went responsive
nonsquared
95
5.2k
Producing Creativity
orderedlist
PRO
341
39k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
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/
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ