PHP code example of ncmbmania / php-ncmb

1. Go to this page and download the library: Download ncmbmania/php-ncmb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ncmbmania / php-ncmb example snippets


    use Ncmb\NCMB;

    $appkey = YOUR_APPLICATION_KEY;
    $clientkey = YOUR_CLIENT_KEY;

    NCMB::initialize($appkey, $clientkey);

    use Ncmb\Object;
    use NCMB\GeoPoint;

    $className = 'FooBar';
    $foobar = new Object($className);
    $foobar->stringKey = 'This is String';
    $foobar->intKey = 1;
    $foobar->dateKey = new DateTime();
    $foobar->geoKey = new GeoPoint(43.223, 133.392);
    $foobar->save();

    use \Ncmb\Query;

    $className = 'FooBar';
    $query = new Query($className);
    $query->equalTo('intKey', 1);
    $foundObj = $query->first();

    use \Ncmb\File;

    // put file
    $file = File::createFromData('hogehoge', 'hoge.txt');
    $file->save();

    // get file
    $file = File::createFromServer('hoge.txt');
    $data = $file->getData();

    use \Ncmb\Script;

    $result = Script::execute('hello.js', ['query' => ['name' => 'NCMB']]);
json
     "ncmbmania/php-ncmb": "*"