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

PHPとmBaaSの美味しい関係

 PHPとmBaaSの美味しい関係

2016年5月21日のPHPカンファレンス福岡2016で発表した資料です。

KOYAMA Tetsuji

May 21, 2016
Tweet

More Decks by KOYAMA Tetsuji

Other Decks in Technology

Transcript

  1. 1)1ͱN#BB4ͷ
    ඒຯ͍ؔ͠܎
    খࢁ఩ࢤ
    !LPZIPHF
    1)1ΧϯϑΝϨϯε෱Ԭ

    View Slide

  2. BCPVU͍͜΄͛
    ‣খࢁ఩ࢤ ͜΍·ͯͭ͡

    ‣ϑϦʔϥϯεϓϩάϥϚʔ
    ‣!LPZIPHF
    ‣χϑςΟΫϥ΢υNPCJMFCBDLFOE

    ΤόϯδΣϦετ
    ‣ࠓظͷΠνΦγΞχϝ͸

    ʮ3Fθϩ͔Β࢝ΊΔҟੈքੜ׆ʯ

    View Slide

  3. Θͨ͠ͱN#BB4
    ‣ࡢ೥ՆΑΓχϑςΟΫϥ΢υNPCJMFCBDLFOE
    ΤόϯδΣϦετ
    ‣"OESPJE4%,Wͷॳظ։ൃʹؔΘΔ
    ‣ϒϩάهࣄΛ͍͔ͭࣥ͘ච
    ‣ษڧձɾΧϯϑΝϨϯεͰͷN#BB4ൃද͸ճ

    View Slide

  4. N#BB4
    ϞόΠϧόοΫΤϯυ
    ΞζΞαʔϏε

    View Slide

  5. #BB4
    ‣1BB4ͷҰछͱݴ͑Δ
    ‣αʔόଆػೳҰࣜΛ"1*Խͯ͠ఏڙ
    ‣εέʔϧʹࣗಈରԠ
    ‣֤छ؅ཧػೳ
    ‣8FCμογϡϘʔυ
    ‣ϝʔϧͦͷଞͷ௨஌

    View Slide

  6. N#BB4
    ϞόΠϧ

    View Slide

  7. ϞόΠϧ։ൃͷಛ௃
    ‣αʔόαΠυٕज़ʹৄ͘͠ͳ͍ ਓ΋͍Δ

    ‣εέʔϧରԠͱ͔উखʹ΍ͬͯ΄͍͠
    ‣ϞόΠϧ޲͚ʹಛԽͨ͠ػೳ
    ‣ϓογϡ௨஌
    ‣Ґஔ৘ใ
    ‣ՄೳͳΒαʔόϨεͰ͍͖͍ͨ

    View Slide

  8. View Slide

  9. N#BB4Λ
    Ͳ͏΍ͬͯ࢖͏ͷ͔

    View Slide

  10. 4%,
    ‣J04ɺ"OESPJEͦΕͧΕʹ༻ҙ͞Ε͍ͯΔ
    ‣J04͸TXJGUधཁ͕ߴ·͍ͬͯΔ
    ‣αʔϏεʹΑͬͯ͸ͦΕҎ֎΋
    ‣+BWB4DSJQU /PEF )5.-

    ‣$ 6OJUZ

    ‣1)1
    ‣3&45"1*

    View Slide

  11. N#BB4Ͱ
    Կ͕Ͱ͖Δͷ͔

    View Slide

  12. N#BB4ͷػೳ
    ‣σʔλϕʔε
    ‣Ϣʔβʔೝূ
    ‣ϑΝΠϧετϨʔδ
    ‣ϓογϡ௨஌
    ‣ͦͷଞ
    ‣ߦಈղੳɺΫϥογϡϨϙʔτɺαʔόϩδο
    ΫɺͳͲͳͲʜ

    View Slide

  13. σʔλϕʔε
    ‣σʔλετΞɺϦΞϧλΠϜ%#ͳͲͱݺ͹ΕΔ
    ‣ΩʔόϦϡʔετΞతͳߴ଎%#
    ‣ಠࣗͷΫΤϦػೳ
    ‣"1*Λݺͼग़͚ͩ͢ͳͷͰɺεέʔϧ͸উखʹߦ
    ΘΕΔ
    ‣΋ͪΖΜαʔόӡ༻͸ඞཁͳ͍

    View Slide

  14. Ϣʔβೝূ
    ‣ొ࿥Ϣʔβͷ؅ཧ
    ‣,74తʹ೚ҙͷଐੑΛࢦఆՄೳ
    ‣0"VUIೝূαϙʔτ͢Δ৔߹΋
    ‣άϧʔϓɺ"$-ػೳΛ࣋ͭ৔߹΋͋Δ

    View Slide

  15. ϑΝΠϧετϨʔδ
    ‣େ͖Ίͷσʔλͷอଘ৔ॴ
    ‣ը૾΍ύονσʔλͳͲ
    ‣"NB[PO4తͳ΋ͷ
    ‣"$-Λ࣋ͭ৔߹΋

    View Slide

  16. ϓογϡ௨஌
    ‣ϓϥοτϑΥʔϜ͝ͱͷҧ͍
    ‣J04"1/4 "QQMF1VTI/PUJGJDBUJPO
    4FSWJDF

    ‣"OESPJE($. (PPHMF$MPVE.FTTBHJOH

    ‣େྔʹૹΔʹ͸ϊ΢ϋ΢͕͍Δ
    ‣ಉ࣌഑৴ɺݸผ഑৴
    ‣͜ͷͨΊ͚ͩʹN#BB4Λ࢖͏ਓ΋ଟ͍

    View Slide

  17. ͦͷଞ
    ‣αʔόϩδοΫ͕໘ന͍
    ‣"NB[PO-BNCEB "[VSF'VODUJPOTͳͲ
    ‣"1*ͰΩοΫͤͯ͞Ұ࿈ͷॲཧΛόονతʹ
    ‣Ϣʔβʔߦಈղੳ͸͜Ε͔Βϗοτ
    ‣ͦΕઐ໳ͷαʔϏε΋͋Δ

    View Slide

  18. N#BB4
    ࠷ۙͷτϐοΫ

    View Slide

  19. 1BSTFͷαʔϏεऴྃ
    ‣'BDFCPPLʹങऩ͞ΕͨN#BB4քͷڊਓ
    ‣೥݄຤ʹαʔϏεΛ׬શऴྃ
    ‣1BSTF4FSWFSΛ044ͱͯ͠ެ։
    ‣Ҡߦɺӡ༻ͷϊ΢ϋ΢ͷ৘ใަ׵͕ίϛϡχςΟ
    Ͱ੝Μ
    ‣ࠃ಺Ͱ΋ࠔ͍ͬͯΔࣄۀձࣾ͸ଟ͍

    View Slide

  20. (PPHMF'JSFCBTF
    ‣೥݄ʹ(PPHMFʹങऩ
    ‣(PPHMF*0ͰαʔϏε಺༰ͷେ෯มߋ
    ‣"OBMZUJDTແঈɾແ੍ݶ
    ‣ϓογϡ௨஌ແঈɾແ੍ݶ
    ‣Ϋϥογϡղੳແঈɾແ੍ݶ
    ‣ϓϥϯ΋γϯϓϧʹ
    ‣ແঈɺ݄ɺैྔ

    View Slide

  21. χϑςΟΫϥ΢υ
    NPCJMFCBDLFOE
    ‣χϑςΟ͕΍͍ͬͯΔN#BB4αʔϏε
    ‣௨শ/$.#
    ‣ࠃ಺Ͱ͸େखʹೖΔ
    ‣ઈࢍʮ1FSTF೉ຽͷۦ͚ࠐΈࣉʯԽͯ͠Δ
    ‣ʮޚࣾ͸1BSTFͷΑ͏ʹ͍͖ͳΓαʔϏεଧͪ
    ੾ͬͨΓ͠ͳ͍Ͱ͢ΑͶ ʯ

    View Slide

  22. Կ͕Ͱ͖Δͷ
    ‣ձһ؅ཧɾೝূ
    ‣εϚϗ΁ͷϓογϡ௨஌
    ‣σʔλετΞ
    ‣,74తͳ΋ͷ
    ‣ϑΝΠϧετΞ
    ‣ΦϒδΣΫτετϨʔδ
    ‣Ґஔ৘ใݕࡧ
    ‣/PEFϞδϡʔϧ࣮ߦ ‏/FX

    View Slide

  23. /$.#4%,
    ‣J04 0CKFDUJWF$

    ‣"OESPJE +BWB

    ‣+BWB4DSJQU /PEF .POBDB

    ‣6OJUZ $

    View Slide

  24. ͏ͪͷݴޠͳ͍ΜͰ͚͢Ͳ
    ‣3&45"1*͕ެ։͞Ε͍ͯ·͢ɻ
    ‣ઌ΄Ͳͷ֤ݴޠ༻4%,΋ɺதͰ͸3&45"1*
    Λୟ͍͍ͯΔ͚ͩɻ
    ‣IUUQNCDMPVEOJGUZDPNEPDDVSSFOU
    SFTUDPNNPOGPSNBUIUNM

    View Slide

  25. 1)1͸·ͩͰ͔͢
    ‣͍͢·ͤΜɺઈࢍ։ൃதͰ͢ɻ
    ‣/$.#ͷશػೳʹରԠ༧ఆ
    ‣1)1Ҏ߱ʹରԠ
    ‣΋͏TIPSUBSSBZTZOUBYͰ͍͍ΑͶ

    View Slide

  26. ࢖༻ྫσʔλετΞ΁ͷอଘ
    use Ncmb\NCMB;
    use Ncmb\Object;
    try {
    $appkey = 'xxxxxxxx';
    $clientkey = 'yyyyyyyy';
    NCMB::initialize($appkey, $clientkey);
    $className = 'myClass';
    $object = new Object($className);
    $object->key1 = 'a';
    $object->key2 = 'b';
    $object->save();
    } catch (Exception $e) {
    die($e->getMessage());
    }

    View Slide

  27. ࢖༻ྫσʔλετΞͷݕࡧ
    use Ncmb\NCMB;
    use Ncmb\Query;
    try {
    $appkey = 'xxxxxxxx';
    $clientkey = 'yyyyyyyy';
    NCMB::initialize($appkey, $clientkey);
    $className = 'myClass';
    $query = new Query($className);
    $query->equalTo('key1', 'a');
    $results = $query->find();
    var_dump(count($results)); // 1
    } catch (Exception $e) {
    die($e->getMessage());
    }

    View Slide

  28. ྫ͑͹ͷ࢖͍ॴ
    ‣ඇৗʹଟ͘ͷඇߏ଄ԽσʔλΛѻ͏
    ‣%#αʔόͷ͓कΓ͸ͨ͘͠ͳ͍
    ‣ඇৗʹଟ͘ͷϢʔβʔΞΧ΢ϯτΛѻ͏
    ‣σʔλ୯ҐͰࡉ͔͘ΞΫηε੍ޚΛ͢Δ
    ‣େྔͷϓογϡ഑৴Λ஗Ԇͳ͘΍Γ͍ͨ

    View Slide

  29. Ͱ΋͓ߴ͍ΜͰ͠ΐ͏
    ‣͓ࢼ͠ແྉϓϥϯ͋Γ·͢
    ‣"1*ϦΫΤετ਺ສճ݄
    ‣ϓογϡ௨஌഑৴਺ສճ݄
    ‣ετϨʔδΤϦΞ(#
    ‣εΫϦϓτ"1*ίʔϧ਺ճ݄
    ‣͔ͦ͜Β্͸ສԁ݄ͷ&YQBSUϓϥϯ

    View Slide

  30. ·ͱΊ
    ‣N#BB4͸ϞόΠϧͷͨΊʮ͚ͩʯͷαʔϏε
    ͡Ό͋Γ·ͤΜ
    ‣͏·͘ར༻ͯ͠ඞཁͳ෦෼͚ͩΛ֎ग़͠Ͱ͖Δ
    ‣/$.#1)14%,͸·ͩ։ൃத
    ‣΋͏গ͠ػೳ࣮૷Ͱ͖ͨΒެ։͠·͢

    View Slide