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

WP-APIが開くWordPressの未来

 WP-APIが開くWordPressの未来

PHPカンファレンス福岡2016での発表資料です。
PDF版のダウンロードは以下のURLからどうぞ。
(PDF版は参照先にハイパーリンクが設定してあります。)
https://www.dropbox.com/s/4bxc3l6y8brqwjv/phpcon-fukuoka-2016.pdf

Takayuki Miyauchi

May 21, 2016
Tweet

More Decks by Takayuki Miyauchi

Other Decks in Technology

Transcript

  1. 81"1*͕੾Γ։͘

    8PSE1SFTTͷະདྷ

    1)1ΧϯϑΝϨϯε෱Ԭ
    ٶ಺ོߦ
    UXJUUFS!NJZB

    View full-size slide

  2. https://ja.amimoto-ami.com/

    View full-size slide

  3. http://vccw.cc/

    View full-size slide

  4. ࠓ೔ͷ಺༰
    w 81"1*ͱ͸ʁ
    w ͳͥ81"1*͕ඞཁͳͷ͔ʁ
    w 81"1*ʹΑΔมԽ
    w ࣄྫ

    View full-size slide

  5. w 8PSE1SFTT͔Β࣮૷͞Εͨ৽ػೳ
    w 8PSE1SFTTΛ+40/3&45"1*Ͱ͝ʹΐ͝ʹΐɻ
    $ curl http://wp-api.dev/wp-json/wp/v2/posts | jq .
    [
    {
    "id": 1,
    "date": "2016-05-17T07:28:32",
    "date_gmt": "2016-05-17T07:28:32",
    "guid": {
    "rendered": "http://wp-api.dev/?p=1"
    },
    "modified": "2016-05-17T07:28:32",
    "modified_gmt": "2016-05-17T07:28:32",
    "slug": "hello-world",
    "type": "post",

    View full-size slide

  6. w ݱ࣌఺ͰϑϧػೳΛ࢖͏ʹ͸81"1*ϓϥάΠϯΛΠ
    ϯετʔϧ͢Δඞཁ͕͋Δɻ
    w 8PSE1SFTTͰίΞʹϚʔδ͞ΕΔ༧ఆɻ
    https://wordpress.org/plugins/rest-api/

    View full-size slide

  7. 8PSE1SFTTͷ৽ػೳ͸ࣄલʹϓϥάΠϯͱͯ͠ϦϦʔε͞Εɺ

    4MBDL΍(JU)VCͰͷٞ࿦ΛܦͯίΞʹϚʔδ͞Ε·͢ɻ
    https://make.wordpress.org/core/features-as-plugins/

    View full-size slide

  8. https://github.com/WP-API

    View full-size slide

  9. w ਖ਼౷೿3&45GVMͳ"1*ɻ
    w ϓϥάΠϯʹΑΓ֦ுՄೳɻͨͱ͑͹ϝλσʔ
    λΛ+40/ʹ௥Ճͨ͠Γͱ͔ɻ
    w औಘ͍ͨ͠هࣄͷύϥϝʔλΛΫΤϦʔจࣈྻ
    Ͱࢦఆ͢Δ͜ͱ͕Մೳɻ

    View full-size slide

  10. /wp-json/wp/v2/posts
    ౤ߘͷҰཡΛऔಘ
    *%͕ͷݻఆϖʔδΛऔಘ
    /wp-json/wp/v2/pages/234
    /wp-json/wp/v2/:object/:id

    View full-size slide

  11. ?filter[s]=hello
    IFMMPؚ͕·ΕΔهࣄΛऔಘ
    ΧςΰϦʔ͕GSVJUTͷهࣄΛऔಘ
    ?filter[category]=fruits
    https://codex.wordpress.org/Class_Reference/WP_Query
    8PSE1SFTTͷ81@2VFSZͷύϥϝʔλ͕࢖༻Մ

    View full-size slide

  12. ஫ҙʂ
    w ΧελϜϑΟʔϧυʢQPTU@NFUBʣ͸σϑΥϧ
    τͰ͸ग़ྗ͞Ε·ͤΜ͠ɺΫΤϦʔʹ࢖༻͢Δ
    ͜ͱ΋Ͱ͖·ͤΜɻ
    ͍ͭͷؒʹ͔αʔυύʔςΟʔͷϓϥάΠϯ͕ॏཁͳ৘ใΛ

    ΧελϜϑΟʔϧυʹอଘ͍ͯ͠Δ͜ͱ͕૝ఆ͞Ε·͢ɻ
    ҆қʹ"1*ʹग़ͦ͏ͱ͠ͳ͍Α͏ʹ஫ҙʂ

    View full-size slide

  13. ΧελϜϑΟʔϧυΛ
    3FTU"1*ʹ௥Ճ͢ΔϓϥάΠϯͷྫ

    View full-size slide

  14. ҎԼ͸P"VUI౳ͷೝূ͕ඞཁ
    w ύεϫʔυอޢ͞Εͨϖʔδɺඇެ։ͷϖʔδɺԼ
    ॻ͖ͳͲͷऔಘɻ
    w هࣄͷ௥Ճ΍Ξοϓσʔτɺ࡟আͳͲɻ

    View full-size slide

  15. ͳͥ81"1*͕ඞཁʁ

    View full-size slide

  16. 69͸௒େࣄʂ
    w ϑϩϯτΤϯυσΟϕϩούʔ͕1)1Λ֮͑ͳ͍ͱ
    ͍͚ͳ͍ͷ͸Ͳ͏Αʁ

    View full-size slide

  17. εέʔϦϯά͕௒໘౗͍͘͞
    ͍·Ͳ͖εέʔϦϯά͸ࣗಈԽ͍ͨ͠ΜͰ͕͢ɻ

    View full-size slide

  18. Ұຕؠ͗͢Δ
    εύήοςΟίʔυͳςʔϚɻେྔͷϓϥάΠϯɻ

    ๲େͳ਺ͷهࣄ΍ը૾σʔλɻ

    ϚΠάϨʔγϣϯ͚ͩͰमཏ৔ɻ
    ͳΜͯܦݧ͋Γ·ͤΜʁ

    View full-size slide

  19. 81"1*ʹΑΔมԽ

    View full-size slide

  20. 8PSE1SFTTͷςʔϚγεςϜ͔Β

    ϑϩϯτΤϯυΛղ์
    w εϚϗΞϓϦɺσεΫτοϓΞϓϦͳͲͷόοΫΤϯυ
    ͱͯ͠ͷ8PSE1SFTT

    View full-size slide

  21. ϚΠΫϩαʔϏεͷҰ෦ͱͯ͠ͷ
    8PSE1SFTT
    w ଞͷ$.4΍ϑϨʔϜϫʔΫ౳ͱͷ༰қͳ࿈ܞ͕Մೳɻ
    Lambda API Gateway

    View full-size slide

  22. ຊ൪Ͱ΋εςʔδϯάͰ΋
    ϥΠϒσʔλ
    w ͩͬͯ"1*ͩ΋Μɻ
    w ϚΠάϨʔγϣϯແ͠Ͱ։ൃΛ࢝ΊΔ͜ͱ΋Մೳɻ

    View full-size slide

  23. εέʔϦϯά ͳʹͦΕʁ
    w ͱʹ͔͘Ωϟογϡͪ͠Ό͑ʂ
    w "84ͷ$MPVE'SPOU΍"1*(BUFXBZ͸௒ศརɻ
    CloudFront CDN

    View full-size slide

  24. ϫʔΫϑϩʔͷվળ
    w όοΫΤϯυͱϑϩϯτΤϯυͷ׬શͳ෼ۀɻ
    w ϑϩϯτΤϯυσΟϕϩούʔ͸όοΫΤϯυ͕
    8PSE1SFTTͰ͋Δ͜ͱΛ஌Δඞཁ͑͞ͳ͍͔΋ɻ

    View full-size slide

  25. w όοΫΤϯυ͸8PSE1SFTTʴ81"1*
    w ϑϩϯτΤϯυ͸ɺ/PEFKT3FBDUɻ
    w ϑϩϯτΤϯυͷΠϯϑϥʹ͸%PDLFSΛ࢖༻ɻ
    w 044Ͱެ։͞Ε͍ͯ·͢ɻ

    View full-size slide

  26. w 81"1*͔Βऔಘͨ͠σʔλΛ/PEFKTαʔόʔܦ༝
    Ͱग़ྗ͢Δ͜ͱͰɺඇಉظॲཧʹΑΔߴ଎ԽΛ࣮ݱɻ
    w /PEFKTαʔόʔଆͰϨεϙϯε͕Ωϟογϡ͞Εͯ
    ͓Γ8PSE1SFTT͕μ΢ϯͯ͠΋αΠτ͸Քಇɻ
    w 8PSE1SFTTͷ؅ཧը໘Λ࢖͏͜ͱͰɺίϯςϯπϥ
    ΠλʔͷֶशίετΛ௿ݮɻ

    View full-size slide

  27. w ଞͷ$.4͔Β8PSE1SFTTʹҠߦɻ
    w ಠ࣮ࣗ૷ͷϓϥάΠϯΛ։ൃͯ͠"1*Խɻ
    w όοΫΤϯυͷ։ൃνʔϜ͸ϑϩϯτΤϯυʹ΄ͱ
    ΜͲؔ༩͓ͯ͠ΒͣɺҠߦίετΛ௿ݮ͢Δ͜ͱʹ
    େ͖͘ߩݙɻ

    View full-size slide

  28. ͦͷଞͷࣄྫ
    w 5IF/FX:PSL5JNFT
    w 8JSFE
    w )BQQZUBCMFT
    w /PNBEPCBTF

    View full-size slide

  29. 81"1*͸8PSE1SFTTͷΤίγεςϜΛ

    ήʔϜνΣϯδ͢ΔଘࡏʹͳΔ͔΋
    w /PEFKTͳͲͷଞͷݴޠ΍πʔϧΛ࢖༻ͨ͠৽͍͠ςʔϚγεςϜɻ
    w ΞϓϦΛ૝ఆͨ͠8PSE1SFTT༻$44ϑϨʔϜϫʔΫɻ
    w 4MBDLͷΑ͏ͳνϟοτΞϓϦέʔγϣϯ
    w ͦͷଞ
    ͍Ζ͍Ζ։ൃͯ͠༡ΜͰ͘ΕΔ

    ΠϯνΩൃ໌ՈΈ͍ͨͳਓΛઈࢍืूதʂ

    View full-size slide