Upgrade to Pro — share decks privately, control downloads, hide ads and more …

BEAR.Sunday のはなし - 第89回PHP勉強会@東京

madapaja
April 28, 2015

BEAR.Sunday のはなし - 第89回PHP勉強会@東京

PHP5.5+ リソース指向フレームワークBEAR.Sundayの紹介です。
第89回PHP勉強会@東京で発表。
Ray.Di, Ray.Aop, BEAR.Resource などについて
ブログ→
http://blog.madapaja.net/entry/2015/04/30/200000

madapaja

April 28, 2015
Tweet

More Decks by madapaja

Other Decks in Programming

Transcript

  1. BEAR.Sunday ͷ͸ͳ͠
    ؠ࡚ߊ࢘ʢ@madapajaʣ
    2015-04-28 ୈ89ճ PHPษڧձˏ౦ژ

    View full-size slide

  2. Who am I?
    • ؠ࡚ߊ࢘ @madapaja
    • Symfony Ϣʔβʔձ
    • ϦδϣϒͰΤϯδχΞͯ͠·͢ʂ
    • ࠷ۙͷۀ຿Ͱ͸ Rails ͕ଟ͍
    • PHPษڧձ@౦ژͷࢀՃ͸ٱ͠ͿΓ
    • 1೥൒μΠΤοτͯ͠ΔͷʹҰ޲ʹݮΒͳ͍ମॏʂʢͯ
    ͔૿͑ͨ……ʣ

    View full-size slide

  3. ͔ͤͬ͘ϦδϣϒͰ
    PHPษڧձ@౦ژ Λ
    ͢Δ͜ͱʹͳͬͨͷͰ
    ൃදͯ͠Έ·͢ʂ

    View full-size slide

  4. ͰɺࢿྉΛ࡞ΔͨΊʹ
    ͍Ζ͍ΖړͬͯͨΒ

    View full-size slide

  5. ʮୈ61ճPHPษڧձ@౦ژʯͰ΋΍ͬͯͨɻ

    View full-size slide

  6. ࠓ೔΋ࣅͨΑ͏ͳ࿩Λ͠·͢
    m(__)m

    View full-size slide

  7. BEAR.Sunday
    ஌ͬͯ·͔͢ʁ

    View full-size slide

  8. BEAR.Sunday
    • ܊ࢁ͞Μʢ@koriymʣͷ࡞͍ͬͯΔϑϨʔϜϫʔΫ
    • PHPNW 2013 Ͱ΋ϓϨθϯςʔγϣϯ͞Εͨ
    • PHP 5.5+ Ϧιʔεࢦ޲ϑϨʔϜϫʔΫ
    • ͜ΜͳαΠτ͕BEAR.SundayͰ࡞ΒΕ͍ͯ·͢
    • Woman.exciteϚϚʢhttp://mama.woman.excite.co.jp/ʣ
    • Project Zuluʢhttp://www.pen-online.jp/ʣ
    • Pen Onlineʢhttp://www.projectzulu.org/ʣ
    • ஌ͬͯΔਓ΋ɺ஌Βͳ͍ਓ΋ BEAR.Sunday ৮ΕͯΈ·͠ΐ͏

    View full-size slide

  9. BEAR.Sunday =
    DI + AOP +
    REST(Hypermedia)

    View full-size slide

  10. BEAR.Sunday =
    Ray.Di + AOP +
    REST(Hypermedia)

    View full-size slide

  11. BEAR.Sunday =
    Ray.Di + Ray.Aop +
    REST(Hypermedia)

    View full-size slide

  12. BEAR.Sunday =
    Ray.Di + Ray.Aop +
    BEAR.Resource

    View full-size slide

  13. BEAR.Sunday =
    Ray.Di + Ray.Aop +
    BEAR.Resource
    2.1.0
    ࡢ೔ϦϦʔε

    View full-size slide

  14. BEAR.Sunday =
    Ray.Di + Ray.Aop +
    BEAR.Resource
    2.1.0
    ࡢ೔ϦϦʔε
    2.1.0

    View full-size slide

  15. BEAR.Sunday =
    Ray.Di + Ray.Aop +
    BEAR.Resource
    2.1.0
    ࡢ೔ϦϦʔε
    2.1.0
    1.0.2

    View full-size slide

  16. Ұͭͣͭઆ໌͠·͢

    View full-size slide

  17. DI = ґଘੑͷ஫ೖ
    ʢDependency injectionʣ

    View full-size slide

  18. ϧʔϧΛهड़͢Δͱ

    View full-size slide

  19. ϧʔϧΛهड़͢Δͱ
    ΦϒδΣΫτ͕஫ೖ͞ΕΔ

    View full-size slide

  20. ϧʔϧΛهड़͢Δͱ
    ΦϒδΣΫτ͕஫ೖ͞ΕΔ
    ར༻ͷࡍʹ͸Injector͔ΒPostΠϯελϯεΛऔಘͯ͠ߦ͏

    View full-size slide

  21. Ray.DiΛར༻͢Δͱ
    • ؀ڥʹΑΓDBΛม͑ͨΓɺCacheγεςϜΛม͑ͨΓ͢
    Δʹ͸ɺModule͚ͩมߋ͢Ε͹ྑ͍
    • PostΫϥε͸ΠϯελϯεΛऔಘͨ࣌͠఺ͰඞཁͳΦϒ
    δΣΫτ͕஫ೖ͞Εͨʢ֎͔Βࣗಈతʹηοτ͞Εͨʣ
    ঢ়ଶ
    • PostΫϥε͕ DBͱ͔Cacheͷ࣮૷Λ஌͍ͬͯΔඞཁ͕
    ͳ͍ʢந৅ΫϥεʹͷΈґଘʣ

    View full-size slide

  22. DIͰಘΒΕΔ͜ͱ
    • ੜ੒ͱར༻ͷ෼཭
    • ґଘੑΛ஫ೖ͢Δ͜ͱͰɺΫϥεؒͷີ݁߹
    ౓ΛݮΒ͢

    View full-size slide

  23. Ray.Di 2.x
    • hhvm ରԠ
    • Qualifier Ξϊςʔγϣϯ΁ͷରԠ
    • toConstructor όΠϯσΟϯάʹΑΔ3rdύʔςΟΫϥε΁ͷ

    όΠϯσΟϯάʹରԠ
    • ScrutinizerΫϦʔϯίʔυΠϯσοΫε10.00ɺςετΧόϨοδ100%
    • ίʔσΟϯά͕OOPʹ
    • Ray.CompilerʹΑΔύϑΥʔϚϯε޲্ͱΠϯελϯεੜ੒ίʔυͷ

    ࣗಈੜ੒ʹରԠ(v2.1)
    • ͳͲ……

    View full-size slide

  24. AOP

    = ΞεϖΫτࢦ޲ϓϩάϥϛϯά
    ʢAspect Oriented Programmingʣ

    View full-size slide

  25. AOP

    = ΞεϖΫτࢦ޲ϓϩάϥϛϯά
    ʢAspect Oriented Programmingʣ
    • ΞεϖΫτʢʹԣஅతؔ৺ࣄʣͷॲཧ
    • ؔ৺ࣄͷ෼཭ʢSoC: Separation of Concernsʣ

    View full-size slide

  26. • Ωϟογϡͷॲཧ͸ Post Ϋϥεͷຊ࣭తؔ৺ࣄͰ͸ͳ͍
    • Post Ϋϥε͸શͯͷϙετΛฦ͢ࣄʹઐ೦Ͱ͖Ε͹ɺ
    ΋ͬͱ޾ͤʹͳΕΔ

    View full-size slide

  27. Ray.Aop Λ࢖༻͢Δͱ

    View full-size slide

  28. Ray.Aop Λ࢖༻͢Δͱ
    PostͰ͸ຊ࣭తؔ৺ࣄʹઐ೦

    View full-size slide

  29. Ray.Aop Λ࢖༻͢Δͱ
    • ΩϟογϡͷॲཧΛ෼཭͠ɺଞͷΩϟογϡͷඞཁͳՕॴͰ
    ΋࠶ར༻Ͱ͖ΔΑ͏ʹͳͬͨ

    View full-size slide

  30. Ray.Aop Λ࢖༻͢Δͱ
    CacheInterceptor Ͱԣஅతؔ৺ࣄΛॲཧ
    • ΩϟογϡͷॲཧΛ෼཭͠ɺଞͷΩϟογϡͷඞཁͳՕॴͰ
    ΋࠶ར༻Ͱ͖ΔΑ͏ʹͳͬͨ

    View full-size slide

  31. Ray.Aop Λ࢖༻͢Δͱ

    View full-size slide

  32. Ray.Aop Λ࢖༻͢Δͱ
    Module ͰΠϯλʔηϓλʔΛద༻

    View full-size slide

  33. Πϯλʔηϓλ
    λΠϚʔ
    όϦσʔγϣϯ
    τϥϯβΫγϣϯ
    ࣮ϝιου
    • ࣮ϝιουΛแΈࠐΉΑ͏ʹԣஅతؔ৺ࣄΛڬΈࠐΉ͜ͱ͕Ͱ͖Δ

    View full-size slide

  34. Ray.Aop 2.x
    • ΞϊςʔγϣϯॱʹΑΔΠϯλʔηϓλͷ࣮ߦ
    • ΞεϖΫτΫϥεͷΦʔτϩʔμʔొ࿥
    • ΧελϜϚονϟʔ΁ͷରԠ
    • ScrutinizerΫϦʔϯίʔυΠϯσοΫε10.00ɺςε
    τΧόϨοδ100%
    • ΑΓޮ཰తͳίʔυࣗಈੜ੒ͷ࢓૊Έ͕ಋೖʢ2.1ʣ
    • ͳͲ……

    View full-size slide

  35. ROP
    = Ϧιʔεࢦ޲ϓϩάϥϛϯά
    ʢResource Oriented Programmingʣ

    View full-size slide

  36. Ϧιʔεࢦ޲ϓϩάϥϛϯά
    • MVCͷΑ͏ʹController͕Model͔ΒσʔλΛड
    ͚औͬͯViewʹ౉͢ͷͰ͸ͳ͘ɺBEARͰ͸֤Ϧ
    ιʔε͕ϨϯμϥʔΛ࣋ͪϦιʔεΛදݱ͢Δ
    Request Representation
    Resource
    Renderer

    View full-size slide

  37. ϦιʔεΦϒδΣΫτ
    • 1ͭͷURIͷϦιʔε͕1ΫϥεʹϚοϓ͞ΕΔ

    View full-size slide

  38. ϦιʔεΦϒδΣΫτ
    • @Link ͸ λάͷΑ͏ʹϦιʔεಉ࢜ΛϦϯΫ͢Δ
    • @Embed͸ λάͷΑ͏ʹϦιʔε͕ଞͷϦιʔεΛຒΊࠐΊΔ

    View full-size slide

  39. ϦιʔεΦϒδΣΫτ
    • @Link ͸ λάͷΑ͏ʹϦιʔεಉ࢜ΛϦϯΫ͢Δ
    • @Embed͸ λάͷΑ͏ʹϦιʔε͕ଞͷϦιʔεΛຒΊࠐΊΔ
    @Link ΞϊςʔγϣϯʹΑΔϦιʔεಉ࢜ͷ઀ଓ

    View full-size slide

  40. ϦιʔεΦϒδΣΫτ
    • @Link ͸ λάͷΑ͏ʹϦιʔεಉ࢜ΛϦϯΫ͢Δ
    • @Embed͸ λάͷΑ͏ʹϦιʔε͕ଞͷϦιʔεΛຒΊࠐΊΔ
    @Link ΞϊςʔγϣϯʹΑΔϦιʔεಉ࢜ͷ઀ଓ
    @Embed ΞϊςʔγϣϯʹΑΔϦιʔεͷຒΊࠐΈ

    View full-size slide

  41. URIͱΫΤϦʔʹΑΔϦιʔεϦΫΤετ

    View full-size slide

  42. BEAR.Resource
    • ΦϒδΣΫτ͕ϦιʔεͷৼΔ෣͍Λ࣋ͭ
    HypermediaϑϨʔϜϫʔΫ
    • URIͱΫΤϦʔʹΑΔϦιʔεΦϒδΣΫτ΁
    ͷΞΫηε
    • ϋΠύʔϦϯΫʹΑΔϦιʔεΦϒδΣΫτؒ
    ͷ࿈ܞʢදݱʣ

    View full-size slide

  43. DI Ͱߏ଄Λɺ
    AOPͰԣஅతؔ৺ࣄΛɺ
    ROPͰϦιʔεಉ࢜Λ
    ݁ͼ͚ͭΔ
    Connecting Framework

    View full-size slide

  44. BEAR.Sunday ͱ͸
    • PHP5.5+ʹରԠͨ͠WebΞϓϦέʔγϣϯϑϨʔϜϫʔΫ
    • RESTͷྗΛҾ͖ग़͠ɺHTTPΛΞϓϦέʔγϣϯϓϩτίϧͱ͠
    ͯѻ͏Ϧιʔεࢦ޲ϑϨʔϜϫʔΫ
    • DIʹΑΔΦϒδΣΫτಉ࢜ɺAOPʹΑΔϨΠϠʔԣஅɺRESTʹ
    ΑΔ৘ใؒΛ઀ଓ͢ΔConnecting ϑϨʔϜϫʔΫ
    • ࢖͍͜ͳ͢ʹ͸ઃܭྗ͕ࢼ͞ΕΔɻ
    • ͚Ͳɺ։ൃऀͱ΋೔ຊޠͰձ࿩Ͱ͖ΔͷͰɺੵۃతʹνϟϨϯδ
    ͯ͠Έͯ͸ʁ
    • ͱΓ͋͑ͣ http://bearsunday.github.io/manuals/1.0/ja/ ͔Β࢝
    ΊͯΈΑ͏ʂ

    View full-size slide

  45. Madapaja.TwigModule
    • https://github.com/madapaja/madapaja.twigmodule
    • BEAR.Sunday ͰͷϦιʔεΛTwigΛ༻͍ͯHTMLͱͯ͠දݱʢϨϯμʔʣ
    ͢ΔͨΊͷΞμϓλΛ࡞Γ·ͨ͠ʂ
    • ͍Ζ͍Ζ଍Γͯͳ͍ͷͰɺͪ͜Β΁ͷϓϧϦΫ΋͓଴͍ͪͯ͠·͢ʂ
    • Α͔ͬͨΒࢼ͍ͯͩ͘͠͞ʂ
    • BEAR.Sunday ͷϚχϡΞϧʹ΋ͪΒͬͱهࡌ͞Ε͍ͯ·͢ʢhttp://
    bearsunday.github.io/manuals/1.0/ja/html.htmlʣ
    • Have fun!

    View full-size slide

  46. ͝੩ௌ͋Γ͕ͱ͏
    ͍͟͝·ͨ͠ʂ

    View full-size slide