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
データの信頼性を支える仕組みと技術
chanyou0311
6
1.7k
株式会社島津製作所_研究開発(集団協業と知的生産)の現場を支える、OSS知識基盤システムの導入
akahane92
1
190
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
320
AIチャットボット開発への生成AI活用
ryomrt
0
150
TypeScript、上達の瞬間
sadnessojisan
11
2.6k
Deno+JSRでパッケージを作って公開する
askua
0
120
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
2
1k
Microsoft MVPになる前、なってから/Fukuoka_Tech_Women_Community_1_baba
nina01
0
180
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
120
エンジニアが一生困らない ドキュメント作成の基本
naohiro_nakata
2
150
Microsoft Intune アプリのトラブルシューティング
sophiakunii
1
420
Can We Measure Developer Productivity?
ewolff
1
110
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
43
13k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
400
GitHub's CSS Performance
jonrohan
1030
460k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Navigating Team Friction
lara
183
14k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Documentation Writing (for coders)
carmenintech
65
4.4k
Happy Clients
brianwarren
97
6.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
The Invisible Side of Design
smashingmag
297
50k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
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/
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ