francimedia/parse-php-sdk
最新稳定版本:1.0.4
Composer 安装命令:
composer require francimedia/parse-php-sdk
包简介
Parse PHP SDK
README 文档
README
The Parse PHP SDK gives you access to the powerful Parse cloud platform from your PHP app or script.
Installation
Get Composer, the PHP package manager. Then create a composer.json file in your projects root folder, containing:
{
"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:
require 'vendor/autoload.php';
Note: The Parse PHP SDK requires PHP 5.4 or newer.
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.
require 'autoload.php';
Initialization
After including the required files from the SDK, you need to initalize the ParseClient using your Parse API keys:
ParseClient::initialize( $app_id, $rest_key, $master_key );
Usage
Check out the Parse PHP Guide for the full documentation.
Add the "use" declarations where you'll be using the classes. For all of the sample code in this file:
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:
$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:
// 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:
// 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:
$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:
$results = ParseCloud::run("aCloudFunction", array("from" => "php"));
Analytics:
ParseAnalytics::track("logoReaction", array( "saw" => "elephant", "said" => "cute" ));
Files:
// 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:
$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.
francimedia/parse-php-sdk 适用场景与选型建议
francimedia/parse-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sdk」 「parse」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 francimedia/parse-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 francimedia/parse-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 francimedia/parse-php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
yii2 xml request parser
Parse promotion arrays from the Wayne State University API
Parse use statements for a reflection object
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Parse verse textual representation into book/chapter/verse ranges
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Parse
- 更新时间: 2014-12-22