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
NCMB PHP SDKでサーバサイドからmBaaSを使おう /ncmb-php-sdk-de...
Search
KOYAMA Tetsuji
August 25, 2017
Programming
1
710
NCMB PHP SDKでサーバサイドからmBaaSを使おう /ncmb-php-sdk-details
2018-08-24 に開催された「NCMB PHP SDKでサーバサイドからmBaaSを使おう」セミナーの発表資料です。
KOYAMA Tetsuji
August 25, 2017
Tweet
Share
More Decks by KOYAMA Tetsuji
See All by KOYAMA Tetsuji
全日本PHPカンファレンス2024スタンプラリーについて/stamprally-php2024
koyhoge
0
110
日本PHPカンファレンス2024スタンプラリーとその実装/phpcon-stamprally
koyhoge
1
950
日本のPHPカンファレンスの歩みと、その辺もろもろ/phpcon_japan_history
koyhoge
0
240
Inside SWOOLE: 非同期処理はどのようにして動くのか/inside_swoole
koyhoge
0
18k
映画を年300本観る技術/watch_300_movies_in_a_year
koyhoge
0
1.1k
Swooleで実装するPHP非同期処理の世界/phpcondo2019-swoole
koyhoge
3
5.1k
CloudFormation と FaaS のはざま - Kubernetes の設計思想を探る -/cf-faas-k8s
koyhoge
0
1.4k
ITイベントマニアから見る技術イベントの動向/techevent
koyhoge
0
300
Skaffoldを使ってKubernetes してみた/skaffold_k8s
koyhoge
2
1.2k
Other Decks in Programming
See All in Programming
Honoの来た道とこれから
yusukebe
19
3k
Identifying User Idenity
moro
6
7.8k
Golang と Erlang
taiyow
8
1.9k
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.2k
Vue.js学習の振り返り
hiro_xre
2
130
色々なIaCツールを実際に触って比較してみる
iriikeita
0
260
Android 15 でアクションバー表示時にステータスバーが白くなってしまう問題
tonionagauzzi
0
140
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.3k
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.6k
Pinia Colada が実現するスマートな非同期処理
naokihaba
2
150
CSC305 Lecture 13
javiergs
PRO
0
130
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
Featured
See All Featured
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
Building an army of robots
kneath
302
42k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
GraphQLとの向き合い方2022年版
quramy
43
13k
Producing Creativity
orderedlist
PRO
341
39k
Gamification - CAS2011
davidbonilla
80
5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Teambox: Starting and Learning
jrom
132
8.7k
Side Projects
sachag
452
42k
What's in a price? How to price your products and services
michaelherold
243
12k
Transcript
/$.#1)14%,Ͱ αʔόαΠυ͔ΒN#BB4 Λ͓͏ খࢁࢤLPZIPHF /$.#ΤόϯδΣϦετ /$.#1)14%,ηϛφʔ
ࣗݾհ খࢁࢤ ͜·ͯͭ͡ ϑϦʔϥϯεΤϯδχΞ ݄ΑΓ/$.#ΤόϯδΣϦετ ϢʔβίϛϡχςΟͷதͷਓ ຊ6/*9Ϣʔβձ ຊ1PTUHSF42-Ϣʔβձ ຊ1)1Ϣʔβձ
!LPZIPHF LPZIPHF
1)14%,ͷུ֓
w N#BB4ຊདྷαʔόӡ༻Λෆཁʹ͢Δͷ w ͔͠͠αʔϏεػೳ͕૿͑ͯ͘ΔͱɺͦΕ͚ͩͰ ऩ·Βͳ͘ͳΔ w ରཱͰͳ͘ิ͢Δؔ N#BB4Ͱαʔό
w ϞόΠϧΞϓϦͱͷ࿈ܞ w όονॻ͖ͨ͘ͳΒͳ͍ w Ϣʔβʹϓογϡ௨ૹΓͨ͘ͳ͍ w ࣗಈεέʔϧ͢Δ,74ͱͯ͠
αʔό͔Βͬͯخ͍͠ͱ͜Ζ
w αʔόଆ͔Β͑Δͷɺݱঢ়Ͱ/PEFKT൛͠ ͔ͳ͍ w +BWB൛"OESPJEʹಛԽ͍ͯͯ͠αʔόଆͰ ͑ͳ͍ w 1)1൛ͷཁͪΒ΄Β͋ͬͨ ެࣜ4%,ͷݶք
w 1)1ଟ͘ͷΣϒͰΘΕ͍ͯΔ w Ϣʔβ͕͍ w ͱ͕͍ͬͯΔձࣾ/PEFΛ͍͍͑ w ΤίγεςϜ͕ීٴ͍ͯ͠Δ w ͕ࣗ1)1Λ͖͔ͩΒ
ͳͥ1)1͔
w QBSTFDPN w 'BDFCPPLʹങऩ͞ΕͨN#BB4αʔϏεͷ ฮ w ݄ʹαʔϏεऴྃ w 1)14%,Λ"4*4ϥΠηϯεͰެ։ 1BSTF1)14%,
w 1BSTFͱ/$.#3&45"1*Α͘ࣅ͍ͯΔ w 1BSTF4%,େมྑ͘Ͱ͖͍ͯͨ w 4%,ͷઃܭͰେมࢀߟʹ͍͍ͤͯͨͩͨ͞ 1BSTF1)14%,
1)14%,ͷ͍ํ ॳڃฤ
w ॳظԽ w Ϣʔβཧ w σʔλετΞ w ϑΝΠϧετΞ w ϓογϡ௨
w εΫϦϓτ 1)14%,ͷ͍ํॳڃฤ
Πϯετʔϧ $ composer install "require": { "ncmbmania/php-ncmb": "*" }, w
$PNQPTFSΛͬͯΠϯετʔϧ͠·͢
ॳظԽ use Ncmb\NCMB; $appKey = 'xxxxxxxxxxxxxxx'; $clientKey = 'yyyyyyyyyyyyyyyy'; NCMB::initialize($appKey,
$clientKey); w ͭͷΩʔΛ༻͍ͯॳظԽ w Ҏ߱ͷαϯϓϧίʔυॳظԽ͞Ε͍ͯΔ͜ͱ͕લఏ w ໊લۭؒ/DNC
ϢʔβཧɿαΠϯΞοϓ use Ncmb\User; $user = new User; $user->userName = 'Ncmb_User';
$user->password = 'si20xG!Ajb5%yu'; $user->signUp(); w Ϣʔβ໊ͱύεϫʔυΛ༻͍ͯ৽نొ
ϢʔβཧɿαΠϯΞοϓ use Ncmb\User; $address = '
[email protected]
'; User::sendRegistrationMail($address); w ϝʔϧΞυϨεѼʹձһొཁٻΛૹ৴ sendRegistrationMail
ϢʔβཧɿϩάΠϯ use Ncmb\User; $userName = 'Ncmb_User'; $password = 'si20xG!Ajb5%yu'; $user
= User::login($userName, $password); w Ϣʔβ໊ͱύεϫʔυΛ༻͍ͯϩάΠϯ
ϢʔβཧɿϩάΞτ use Ncmb\User; User::logout(); w ϩάΞτ͢Δ͚ͩ
ϢʔβཧɿϩάΠϯதϢʔβ use Ncmb\User; $user = User::getCurrentUser(); w ݱࡏϩάΠϯ͍ͯ͠ΔϢʔβΛऔಘ
ϢʔβཧɿϢʔβͷআ use Ncmb\User; $userId = 'NmsV9iGunSl6o8Fg'; User::unregister($userId); w ݱࡏϩάΠϯ͍ͯ͠ΔϢʔβΛऔಘ w
͢ͷϢʔβͷPCKFDU*E w /$.#ଆͰࣗಈͰൃߦ͞ΕΔ
ϢʔβཧɿϢʔβʹՃใΛՃ w 6TFSΫϥε0CKFDUΛܧঝ͍ͯ͠ΔͷͰɺՃ ใΛՃͰ͖Δ use Ncmb\User; $userName = 'Ncmb_User'; $password
= 'si20xG!Ajb5%yu'; $user = User::login($userName, $password); $user->age = 30; $user->rank = 27; $user->save();
σʔλετΞ w a/DNCa0CKFDUΫϥεΛ༻͍Δ w a/DNCa6TFSΛ࢝Ίଟ͘ͷΫϥεͷΫϥεʹ ͳ͍ͬͯΔɻ
σʔλετΞɿอଘ w ΦϒδΣΫτͷϓϩύςΟʹΛηοτͯ͠ɺ TBWF ϝιουΛݺͿ use Ncmb\Object; $className = 'example';
$obj = new Object($className); $obj->intKey = 1; $obj->floatKey = 1.0; $obj->stringKey = 'String'; $obj->dateKey = new DateTime(); $obj->save();
σʔλετΞɿอଘ w Ңܦ w TFU ϝιου use Ncmb\Object; use Ncmb\GeoPoint;
$className = 'example'; $obj = new Object($className); $geoPoint = new GeoPoint(35.1, 139.2); $obj->set('geoKey', $geoPoint); $obj->save();
σʔλετΞɿอଘ w ྻʹTFU"SSBZ ϝιουΛ༻͍Δ use Ncmb\Object; $className = 'example'; $obj
= new Object($className); $obj->setArray('arrayKey', [1, 2, 3]); $obj->save();
σʔλετΞɿJEΛࢦఆͨ͠ಡࠐ w PCKFDU*E͕͢Ͱʹ͔͍ͬͯΔ߹ w a/DNCa0CKFDUίϯετϥΫλʹPCKFDU*EΛ͢ w GFUDI ϝιουͰಡࠐΈ use Ncmb\Object;
$className = 'example'; $objectId = '3Dw7EnByRYvtZ3rh'; $obj = new Object($className, $objectId); $obj->fetch();
σʔλετΞɿಛఆͷ݅Ͱಡࠐ w PCKFDU*E͕͔͍ͬͯͳ͍߹ಛఆ݅ͷݕࡧ ʹɺa/DNCa2VFSZΫϥεΛ͏ use Ncmb\Query; $className = 'example'; $query
= new Query($className); $query->equalTo('intKey', 1); $objs = $query->find();
σʔλετΞɿσʔλͷߋ৽ w ಡΈࠐΜͩ0CKFDUʹରͯ͠ɺσʔλΛՃมߋ ͠TBWF ͢Δ͚ͩɻ use Ncmb\Object; $className = 'example';
$objectId = '3Dw7EnByRYvtZ3rh'; $obj = new Object($className, $objectId); $obj->fetch(); $obj->appendKey = 'sample'; $obj->save();
ϑΝΠϧετΞ w ςΩετɺը૾ɺԻͳͲ༷ʑͳσʔλΛ֨ೲͰ ͖ΔετϨʔδ w /DNCa'JMFΫϥεΛ༻͍Δ
ϑΝΠϧετΞอଘ w อଘ͢Δσʔλͷ༰ɺ/$.#্ͷϑΝΠϧ໊ Λࢦఆͯ͠ɺ'JMFDSFBUF'SPN%BUB ϝιου ΛݺͿ use Ncmb\File; $data =
'sample file data'; $fileName = 'sample.txt'; $file = File::createFromData($data, $fileName); $file->save();
ϑΝΠϧετΞಡࠐΈ w ϑΝΠϧ໊Λࢦఆͯ͠ɺ'JMFDSFBUF'SPN4FSWFS ͰpMFΦϒδΣΫτΛ࡞Δ w HFU%BUB ϝιουͰσʔλΛऔಘ use Ncmb\File; $fileName
= 'sample.txt'; $file = File::createFromServer($fileName); $data = $file->getData();
ϑΝΠϧετΞݕࡧ w 'JMFHFU2VFSZ ͰϑΝΠϧετΞ༻ͷ2VFSZΦ ϒδΣΫτΛऔಘ w ͋ͱࣗ༝ʹ݅Λࢦఆ use Ncmb\File; $query
= File::getQuery(); $file = $query ->equalTo('fileName', 'sample.txt') ->first(); $data = $file->getData();
ϓογϡ௨ૹ৴ w ඞཁͳύϥϝʔλΛઃఆͯ͠ a/DNCa1VTITFOE ΛݺͿ͚ͩ use Ncmb\Push; $options = [
'immediateDeliveryFlag' => true, 'title' => 'NCMB push', 'message' => 'sample message', 'target' => ['android'], ]; $pushId = Push::send($options);
ϓογϡ௨Φϓγϣϯ w ࢦఆͰ͖ΔΦϓγϣϯେมଟ͍ w ʮ3&45"1*ϦϑΝϨϯεϓογϡ௨ొʯ Λࢀরͷ͜ͱ • http://mb.cloud.nifty.com/doc/current/ rest/push/pushRegistration.html
ϓογϡ௨ݕࡧ w 1VTIHFU2VFSZ ϝιουͰ2VFSZΦϒδΣ ΫτΛऔಘ use Ncmb\Push; $query = Push::getQuery();
$query->equalTo('status', Push::STAT_ERROR); $pushes = $query->find();
ϓογϡ௨আ w 1VTIEFMFUF ʹPCKFDU*EΛ͢ w ҎԼਖ਼ৗऴྃͨ͠ϓογϡ௨Λશͯআ͢Δྫ use Ncmb\Push; $query =
Push::getQuery(); $query->equalTo('status', Push::STAT_SEND_OK); $pushes = $query->find(); foeach ($pushes as $push) { Push::delete($push->getObjectId()); }
εΫϦϓτ࣮ߦ w "1*͔Βୟ͚Δͷ࣮ߦػೳͷΈ w a/DNCa4DSJQUFYFDVUF Λ༻͍Δ use Ncmb\Script; $script =
'sample.js'; $params = [ 'query' => ['name' => 'NCMB Tarou'], ]; $result = Script::execute($script, $params);
εΫϦϓτ(&5Ҏ֎ͷϝιου w a/DNCa4DSJQUFYFDVUF ͷୈҾ use Ncmb\Script; $script = 'sample.js'; $params
= [ 'query' => ['name' => 'NCMB Tarou'], ]; $method = 'PUT'; $result = Script::execute($script, $params $method);
1)14%,ͷ͍ํ ্ڃฤ
w "$- w ϩʔϧ w ϦϨʔγϣϯ w ϙΠϯλʔ w 2VFSZ
w ಛघΦϖϥϯυ w ಈ࡞ઃఆͷ্ॻ͖ 1)14%,ͷ͍ํ্ڃฤ
"$- w "DDFTT$POUSPMM-JTU w /DNCa"DMΛ༻͍Δ use Ncmb\Acl; $acl = new
Acl; $acl ->setPublicReadAccess(true) ->setPublicWriteAccess(true);
"$-ηοτ w a/DNCa0CKFDUTFU"DM Λ༻͍Δ use Ncmb\Object; $obj = new Object('example');
$obj->key1 = 'val1'; $obj->setAcl($acl); $obj->save();
"$-ࢦఆํ๏ w a/DNCa"DMͷϝιου setReadAccess: ಛఆϢʔβͷಡࠐݖݶηοτ getReadAccess: ಛఆϢʔβͷಡࠐݖݶήοτ setWriteAccess: ಛఆϢʔβͷॻࠐݖݶηοτ getWriteAccess:
ಛఆϢʔβͷॻࠐݖݶήοτ {set,get}Public{Read,Write}Access: Ұൠʹର͢Δݖݶ getRole{Read,Write}Access: setRole{Read,Wreite}AccessWithName: ϩʔϧʹର͢Δݖݶ
"$-ࢦఆྫ w શһ͕ಡΊΔ w VTFSͱVTFS͚ͩॻ͚Δ use Ncmb\Acl; $acl = new
Acl; $acl ->setPublicReadAccess(true) ->setWriteAccess($user1, true) ->setWriteAccess($user2, true);
ϩʔϧ w "$-ʹର͢ΔϢʔβͷηοτ use Ncmb\Role; $roleName = 'myRole'; $role =
Role::createRole($roleName); $role->getUsers()->add($user1); $role->getUsers()->add($user2); $role->save(); $acl = new Acl; $acl->setRoleWriteAccessWithName($roleName, true);
ϩʔϧೖΕࢠ w ϩʔϧʹϩʔϧΛՃ use Ncmb\Role; $role1 = Role::createRole('childRole'); $role1->getUsers()->add($user1); $role1->getUsers()->add($user2);
$role1->save(); $role2 = Role::createRole('parentRole'); $role2->getRoles()->add($role1); $role2->save();
ϙΠϯλ w ΦϒδΣΫτʹผΦϒδΣΫτͷࢀরΛՃ use Ncmb\Object; $className = 'example'; $obj1 =
new Object($className, 'Tf1DG2Bvlf4mXn0a'); $obj1->fetch(); $obj2 = new Object($className); $obj2->pointerKey = $obj1; $obj2->save();
ϦϨʔγϣϯ w ϙΠϯλͱಉ༷ʹผΦϒδΣΫτͷࢀরΛՃ w ಉҰΫϥεʹݶΒΕΔ͕ɺෳͷΦϒδΣΫτΛઃ ఆͰ͖Δ use Ncmb\Object; // $obj,$obj2
ಡࠐࡁΈͱ͢Δ $obj = new Object('example'); $relation = $obj->getRelation('relKey', 'example'); $relation->add($obj1); $relation->add($obj2); $obj->save();
2VFSZ w ݕࡧͷͨΊͷ൚༻Ϋϥε w ߜΓࠐΈ༻ͷϝιουΛඋ͑Δ
2VFSZ༻๏ w 0CKFDUͷݕࡧ2VFSZΛΫϥε໊Λͯ͠OFX w ͦΕҎ֎֤ΫϥεͷHFU2VFSZ ϝιου use Ncmb\Query; $className =
'example'; $query = new Query($className); $query->equalTo('intKey', 1); $objs = $query->find(); $query = Push::getQuery();
2VFSZͷ݅ઃఆ w a/DNCa2VFSZΛ༻͍༷ͯʑͳ݅ͰݕࡧͰ͖Δ equalTo: ͕͍͠ notEqualTo: ͕͘͠ͳ͍ lessThan: ࢦఆͨ͠ΑΓখ͍͞($lt) lessThanOrEqual:
ࢦఆͨ͠ҎԼ ($lte) greaterThan: ࢦఆͨ͠ΑΓେ͖͍ ($gt) greaterThanOrEqual: ࢦఆͨ͠Ҏ্ ($gte) containedIn: ؚ͕·ΕΔ ($in) notContainedIn: ؚ͕·Εͳ͍ ($nin)
2VFSZͷ݅ઃఆ ଓ͖ exists: ͕ଘࡏ͢Δ ($exists) doesNotExists: ͕ଘࡏ͠ͳ͍ regex: ਖ਼نදݱʹϚον ($regex)
inArray: ྻʹؚ·ΕΔ ($inArray) notInArray: ྻʹؚ·Εͳ͍ ($ninArray) containsAll: ͯ͢ͷؚ͕·ΕΔ ($all) matchesQuery: αϒΫΤϦʹ߹க͢ΔσʔλΛϙΠϯ λͱ͍ͯ࣋ͬͯ͠Δ ($inQuery) relatedTo: ΦϒδΣΫτID͕ࢦఆ͞ΕͨͷϦϨʔγϣϯʹඥͮ͘ࢠ
2VFSZpOEͱpSTU w pOE ͯ͢ฦ͢ w pSTU ࠷ॳͷͭͷΈ use Ncmb\Query; $className
= 'example'; $query = new Query($className); $query->equalTo('category', 5); $obj = $query->first(); echo $obj->name;
ಛघΦϖϥϯυ w 3&45"1*Ͱʮ@@PQʯͰࢦఆ͞ΕΔ w ΠϯΫϦϝϯτɺྻͷՃআͳͲ
ΦϖϥϯυΠϯΫϦϝϯτ use Ncmb\Object; $obj = new Object('example', 'xxxxxxxx'); $obj->fetch(); $obj->increment('intKey',
2); $obj->save(); w ݱࡏʹࢦఆͨ͠ΛՃ
Φϖϥϯυ"EE use Ncmb\Object; $obj = new Object('example'); $obj->setArray('arrKey', [1, 2,
3]); $obj->save(); $obj->add('arrKey', [10, 11]); $obj->save(); w ྻʹΛՃ
Φϖϥϯυ"EE6OJRVF use Ncmb\Object; $obj = new Object('example'); $obj->setArray('arrKey', [1, 2,
3]); $obj->save(); $obj->addUnique('arrKey', [2, 3, 4]); $obj->save(); w ྻʹΛՃ ॏෳՃ͠ͳ͍
Φϖϥϯυ3FNPWF use Ncmb\Object; $obj = new Object('example'); $obj->setArray('arrKey', [1, 2,
3]); $obj->save(); $obj->remove('arrKey', [2, 3]); $obj->save(); w ྻ͔ΒΛআ
ಈ࡞ઃఆͷ্ॻ͖ w ඪ४ͷઃఆΛม͍͑ͨ͜ͱ··͋Δ w αʔϏεͷΤϯυϙΠϯτ͕มΘΔ w ϩʔΧϧʹϑΣΠΫ"1*αʔόΛཱͯΔ w /$.#JOJUJBMJ[F ͷΦϓγϣϯύϥϝʔλͰ্
ॻ͖
ಈ࡞ઃఆͷ্ॻ͖ྫ w ϩʔΧϧͷϙʔτʹϑΣΠΫαʔόΛཱͯͨྫ use Ncmb\NCMB; $appKey = 'xxxxxxxxxxxxxxx'; $clientKey =
'yyyyyyyyyyyyyyyy'; $config = [ 'apiHost' => 'localhost', 'scriptApiHost' => 'localhost', 'port' => 10080, 'protocol' => 'http', ]; NCMB::initialize($appKey, $clientKey, $config);
ఆྫ ϓογϡ௨ͷ߹
Ұׅ৴ͱݸผ৴ w શମʹ͚ͯͷࠂͱϢʔβݸਓͷ௨ w DIBOOFMΛར༻͢Δ w εϚϗΞϓϦଆͷ৴ొ࣌ʹଐੑΛՃ͠ ͓ͯ͘ w Ϣʔβ*%
ϩάΠϯ͢ΔͳΒ w ྸɺੑผɺډॅɺΈ
ͲͪΒͰߜΓࠐΈ w ৴ใ *OTUBMMBUJPO ʹ֤छଐੑΛՃ w 1VTITFOE ͷTFBSDI$POEJUJPOͰࢦఆ w ৴ใʹϢʔβ*%ͷΈՃ
w 6TFSͰߜΓࠐΜͩ*EΛTFBSDI$POEJUJPOʹࢦ ఆ
ߜΓࠐΈ৴ w ৴ొ࣌ʹɺډॅͱ͕ηοτ͞Ε͍ͯΔͱ͢Δ use Ncmb\Push; $options = [ 'target' =>
['android', 'ios'], 'searchCondition' => [ 'place' => 'Kanagawa', 'age' => '30s', ], : ]; $pushId = Push::send($options);
ݸผ৴ w ৴ొ࣌ʹɺVTFS*E͕ొ͞Ε͍ͯΔͱ͢Δ use Ncmb\Push; $options = [ 'target' =>
['android', 'ios'], 'searchCondition' => [ 'userId' => 'xxxxxxxxx', ], : ]; $pushId = Push::send($options);
1)14%, ෦ղઆ
1BSTF4%,͔Βม͑ͨͱ͜Ζ w ໊લۭؒ w 1BSTFa1BSTF0CKFDU /DNCa0CKFDU w 1BSTFa*OUFSOBMa4FU0QFSBUJPO /DNCa0QFSBUJPOa4FU w
)551ϥΠϒϥϦ w 1BSTFDVSMؔ /$.#(V[[MF)UUQa$MJFOU w ͦͷଞ͍Ζ͍Ζ
"QJ$MJFOUΫϥε w /DNC"QJ$MJFOUQIQ w 3&45"1*ϦΫΤετૹड৴ͷຊମ w "QJ$MJFOUSFRVFTU ͕ૹड৴ͷ࣮ମ w "QJ$MJFOUTJHO
Ͱγάωνϟੜ w TFTTJPO5PLFOΛอ࣋͢ΔͨΊͷTUPSBHF࣋ͬ ͍ͯΔ
4UPSBHF*OUFSGBDF w TFTTJPO5PLFOΛอ࣋͢ΔͨΊͷετϨʔδ*' w ࣮ͱͯ͠ҎԼͷͭ w /DNCa4UPSBHFa4FTTJPO1)1ηογϣϯ w /DNCa4UPSBHFa.FNPSZϝϞϦ ྻ
w 1)1ηογϣϯ͕༗ޮͳڥͰ4FTTJPO͕બ ΕΔ
&ODPEFS w 1)1ͷมΛ/$.#3&45"1*ͷσʔλදݱʹม ͢Δ w &ODPEBCMF*OUBSGBDFΛ࣮͍ͯͨ͠ΒFODPEF ϝ ιουΛݺͼग़͢ use Ncmb\Encoder;
$encoded = Encoder::encode(new DateTime()); var_dump($encoded); // array(2) { // ["__type"]=> // string(4) "Date" // ["iso"]=> // string(24) "2017-08-24T09:01:39.000Z" // }
/DNCa0QFSBUJPOa w ΦϖϥϯυͷͨΊʹͦΕͧΕͷॲཧΛߦ͏ w 'JFME0QFSBUJPO*OUFSGBDF w BQQMZ ΦϖϥϯυΛద༻͢Δ w NFSHF8JUI1SFWJPVT
લͷΦϖϥϯυͱ౷ ߹͢Δ
/DNCa0CKFDU w σʔλετΞͷத֩ w ͭͷϓϩύςΟ w TFSWFS%BUBαʔό͔Βऔಘͨ͠σʔλ w FTUJNBUFE%BUBΤϛϡϨʔγϣϯޙσʔλ w
PQFSBUJPO4FUΦϖϥϯυू߹
·ͱΊ w /$.#1)14%,ʹ͍ͭͯৄࡉʹղઆ͠·ͨ͠ w 4%,ΘΕͯͳΜ΅Ͱ͢ͷͰͬͯΈͯԼ͍͞ w γϯϓϧͳߟ͑ํͷ"1*Ͱɺ࣮͢ΔͷҊ֎ େมͱ͍͏͜ͱΛࢥ͍Γ·ͨ͠