2017 © Pedro Peláez
 

library parse-php-sdk

Parse PHP SDK

image

francimedia/parse-php-sdk

Parse PHP SDK

  • Tuesday, December 23, 2014
  • by francimedia
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 358 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Parse PHP SDK

The Parse PHP SDK gives you access to the powerful Parse cloud platform from your PHP app or script., (*1)

Installation

Get Composer, the PHP package manager. Then create a composer.json file in your projects root folder, containing:, (*2)

{
  "require": {
    "parse/php-sdk" : "1.0.*"
  }
}

Run "composer install" to download the SDK and set up the autoloader, and then require it from your PHP script:, (*3)

require 'vendor/autoload.php';

Note: The Parse PHP SDK requires PHP 5.4 or newer., (*4)

Alternative Method

If you don't want to use Composer, you can include the autoload.php file in your code to automatically load the Parse SDK classes., (*5)

require 'autoload.php';

Initialization

After including the required files from the SDK, you need to initalize the ParseClient using your Parse API keys:, (*6)

ParseClient::initialize( $app_id, $rest_key, $master_key );

Usage

Check out the Parse PHP Guide for the full documentation., (*7)

Add the "use" declarations where you'll be using the classes. For all of the sample code in this file:, (*8)

use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParsePush;
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;

Objects:, (*9)

$object = ParseObject::create("TestObject");
$objectId = $object->getObjectId();
$php = $object->get("elephant");

// Set values:
$object->set("elephant", "php");
$object->set("today", new DateTime());
$object->setArray("mylist", [1, 2, 3]);
$object->setAssociativeArray(
  "languageTypes", array("php" => "awesome", "ruby" => "wtf")
);

// Save:
$object->save();

Users:, (*10)

// Signup
$user = new ParseUser();
$user->setUsername("foo");
$user->setPassword("Q2w#4!o)df");
try {
  $user->signUp();
} catch (ParseException $ex) {
  // error in $ex->getMessage();
}

// Login
try {
  $user = ParseUser::logIn("foo", "Q2w#4!o)df");
} catch(ParseException $ex) {
  // error in $ex->getMessage();
}

// Current user
$user = ParseUser::getCurrentUser();

Security:, (*11)

// Access only by the ParseUser in $user
$userACL = ParseACL::createACLWithUser($user);

// Access only by master key
$restrictedACL = new ParseACL();

// Set individual access rights
$acl = new ParseACL();
$acl->setPublicReadAccess(true);
$acl->setPublicWriteAccess(false);
$acl->setUserWriteAccess($user, true);
$acl->setRoleWriteAccessWithName("PHPFans", true);

Queries:, (*12)

$query = new ParseQuery("TestObject");

// Get a specific object:
$object = $query->get("anObjectId");

$query->limit(10); // default 100, max 1000

// All results:
$results = $query->find();

// Just the first result:
$first = $query->first();

// Process ALL (without limit) results with "each".
// Will throw if sort, skip, or limit is used.
$query->each(function($obj) {
  echo $obj->getObjectId();
});

Cloud Functions:, (*13)

$results = ParseCloud::run("aCloudFunction", array("from" => "php"));

Analytics:, (*14)

ParseAnalytics::track("logoReaction", array(
  "saw" => "elephant",
  "said" => "cute"
));

Files:, (*15)

// Get from a Parse Object:
$file = $aParseObject->get("aFileColumn");
$name = $file->getName();
$url = $file->getURL();
// Download the contents:
$contents = $file->getData();

// Upload from a local file:
$file = ParseFile::createFromFile(
  "/tmp/foo.bar", "Parse.txt", "text/plain"
);

// Upload from variable contents (string, binary)
$file = ParseFile::createFromData($contents, "Parse.txt", "text/plain");

Push:, (*16)

$data = array("alert" => "Hi!");

// Push to Channels
ParsePush::send(array(
  "channels" => ["PHPFans"],
  "data" => $data
));

// Push to Query
$query = ParseInstallation::query();
$query->equalTo("design", "rad");
ParsePush::send(array(
  "where" => $query,
  "data" => $data
));

Contributing / Testing

See the CONTRIBUTORS.md file for information on testing and contributing to the Parse PHP SDK. We welcome fixes and enhancements., (*17)

The Versions

23/12 2014

dev-master

9999999-dev https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

23/12 2014

dev-develop

dev-develop https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

17/11 2014

1.0.4

1.0.4.0 https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

23/10 2014

dev-config

dev-config https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

10/10 2014

1.0.3

1.0.3.0 https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

24/09 2014

1.0.2

1.0.2.0 https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

22/09 2014

dev-gFosco.saveMethods

dev-gFosco.saveMethods https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

22/09 2014

dev-gFosco.file-delete

dev-gFosco.file-delete https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

23/08 2014

1.0.1

1.0.1.0 https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse

05/08 2014

1.0.0

1.0.0.0 https://github.com/parseplatform/parse-php-sdk

Parse PHP SDK

  Sources   Download

Parse Platform License

The Requires

  • php >=5.4.0
  • ext-curl *
  • ext-json *

 

The Development Requires

sdk parse