{"id":13405224,"url":"https://github.com/parse-community/parse-php-sdk","last_synced_at":"2025-12-17T01:31:03.866Z","repository":{"id":18861205,"uuid":"22077884","full_name":"parse-community/parse-php-sdk","owner":"parse-community","description":"The PHP SDK for Parse Platform","archived":false,"fork":false,"pushed_at":"2023-05-13T20:21:08.000Z","size":3582,"stargazers_count":811,"open_issues_count":6,"forks_count":347,"subscribers_count":83,"default_branch":"master","last_synced_at":"2024-04-14T13:08:29.786Z","etag":null,"topics":["parse-server","php","sdk"],"latest_commit_sha":null,"homepage":"https://parseplatform.org/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parse-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"parse-community","patreon":null,"open_collective":"parse-server","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2014-07-21T19:51:32.000Z","updated_at":"2024-03-31T06:24:10.000Z","dependencies_parsed_at":"2023-09-29T07:19:34.814Z","dependency_job_id":null,"html_url":"https://github.com/parse-community/parse-php-sdk","commit_stats":{"total_commits":305,"total_committers":51,"mean_commits":5.980392156862745,"dds":0.862295081967213,"last_synced_commit":"353a85bfc9cb8e151c45f5fad19014d86b084cb4"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parse-community%2Fparse-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parse-community","download_url":"https://codeload.github.com/parse-community/parse-php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515567,"owners_count":20303258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parse-server","php","sdk"],"created_at":"2024-07-30T19:01:57.561Z","updated_at":"2025-12-17T01:31:03.458Z","avatar_url":"https://github.com/parse-community.png","language":"PHP","funding_links":["https://github.com/sponsors/parse-community","https://opencollective.com/parse-server"],"categories":["PHP"],"sub_categories":[],"readme":"![parse-repository-header-sdk-php](https://user-images.githubusercontent.com/5673677/235324256-42e13836-b26a-4de0-a5c7-b979bc5aff2c.png)\n\n---\n\n[![Build Status CI release](https://github.com/parse-community/parse-php-sdk/workflows/ci/badge.svg?branch=master)](https://github.com/parse-community/parse-php-sdk/actions?query=workflow%3Aci+branch%3Amaster)\n[![Snyk Badge](https://snyk.io/test/github/parse-community/parse-php-sdk/badge.svg)](https://snyk.io/test/github/parse-community/parse-php-sdk)\n[![Coverage](http://codecov.io/github/parse-community/parse-php-sdk/coverage.svg?branch=master)](http://codecov.io/github/parse-community/parse-php-sdk?branch=master)\n[![auto-release](https://img.shields.io/badge/%F0%9F%9A%80-auto--release-9e34eb.svg)](https://github.com/parse-community/parse-dashboard/releases)\n\n[![PHP Version](https://img.shields.io/badge/php-8.1,_8.2,_8.3-green.svg?logo=php\u0026style=flat)](https://php.org/)\n\n[![packagist latest version](https://img.shields.io/packagist/v/parse/php-sdk)](https://packagist.org/packages/parse/php-sdk)\n\n[![Backers on Open Collective](https://opencollective.com/parse-server/backers/badge.svg)][open-collective-link]\n[![Sponsors on Open Collective](https://opencollective.com/parse-server/sponsors/badge.svg)][open-collective-link]\n[![Forum](https://img.shields.io/discourse/https/community.parseplatform.org/topics.svg)](https://community.parseplatform.org/c/client-sdks/javascript-sdk)\n[![Twitter](https://img.shields.io/twitter/follow/ParsePlatform.svg?label=Follow\u0026style=social)](https://twitter.com/intent/follow?screen_name=ParsePlatform)\n\n---\n\nA library that gives you access to the powerful Parse Server backend from your PHP app. For more information on Parse and its features, see [the website](https://parseplatform.org), [the PHP guide](https://docs.parseplatform.org/php/guide/), [the Cloud Code guide](https://docs.parseplatform.org/cloudcode/guide/) or [API Reference](https://parseplatform.org/parse-php-sdk/).\n\n---\n\n## Table of Contents \u003c!-- omit in toc --\u003e\n\n- [Compatibility](#compatibility)\n- [Installation](#installation)\n  - [Install with Composer](#install-with-composer)\n  - [Install with Git](#install-with-git)\n  - [Install with another method](#install-with-another-method)\n- [Setup](#setup)\n  - [Initializing](#initializing)\n  - [Server URL](#server-url)\n  - [Server Health Check](#server-health-check)\n  - [Http Clients](#http-clients)\n  - [Alternate CA File](#alternate-ca-file)\n- [Getting Started](#getting-started)\n  - [Use Declarations](#use-declarations)\n  - [Parse Objects](#parse-objects)\n  - [Users](#users)\n    - [Session Id and Session Fixation](#session-id-and-session-fixation)\n    - [Verification Emails](#verification-emails)\n  - [ACLs](#acls)\n  - [Queries](#queries)\n    - [Aggregate](#aggregate)\n    - [Distinct](#distinct)\n    - [Relative Time](#relative-time)\n  - [Cloud Functions](#cloud-functions)\n  - [Cloud Jobs](#cloud-jobs)\n  - [Config](#config)\n  - [Analytics](#analytics)\n  - [Files](#files)\n  - [Push](#push)\n    - [Push to Channels](#push-to-channels)\n    - [Push with Query](#push-with-query)\n    - [Push with Audience](#push-with-audience)\n    - [Push Status](#push-status)\n  - [Server Info](#server-info)\n    - [Version](#version)\n    - [Features](#features)\n  - [Schema](#schema)\n    - [Index](#index)\n    - [Purge](#purge)\n  - [Logs](#logs)\n- [Contributing / Testing](#contributing--testing)\n\n## Compatibility\n\nThe Parse PHP SDK is continuously tested with the most recent releases of PHP to ensure compatibility. We follow the [PHP Long Term Support plan](https://www.php.net/supported-versions.php) and only test against versions that are officially supported and have not reached their end-of-life date.\n\n| Version | End-of-Life | Compatible |\n|---------|-------------|------------|\n| PHP 8.2 | Dec 2024    | ✅ Yes      |\n| PHP 8.1 | Nov 2023    | ✅ Yes      |\n\n## Installation\nThere are various ways to install and use this sdk. We'll elaborate on a couple here.\nNote that the Parse PHP SDK requires PHP 5.4 or newer. It can also run on HHVM (recommended 3.0 or newer).\n\n### Install with Composer\n\n[Get Composer], the PHP package manager. Then create a composer.json file in\n your projects root folder, containing:\n\n```json\n{\n    \"require\": {\n        \"parse/php-sdk\" : \"1.5.*\"\n    }\n}\n```\n\nRun \"composer install\" to download the SDK and set up the autoloader,\nand then require it from your PHP script:\n\n```php\nrequire 'vendor/autoload.php';\n```\n\n### Install with Git\n\nYou can clone down this sdk using your favorite github client, or via the terminal.\n```bash\ngit clone https://github.com/parse-community/parse-php-sdk.git\n```\n\nYou can then include the ```autoload.php``` file in your code to automatically load the Parse SDK classes.\n\n```php\nrequire 'autoload.php';\n```\n\n### Install with another method\n\nIf you downloaded this sdk using any other means you can treat it like you used the git method above.\nOnce it's installed you need only require the `autoload.php` to have access to the sdk.\n\n## Setup\n\nOnce you have access to the sdk you'll need to set it up in order to begin working with parse-server.\n\n### Initializing\n\nAfter including the required files from the SDK, you need to initialize the ParseClient using your Parse API keys:\n\n```php\nParseClient::initialize( $app_id, $rest_key, $master_key );\n```\n\nIf your server does not use or require a REST key you may initialize the ParseClient as follows, safely omitting the REST key:\n\n```php\nParseClient::initialize( $app_id, null, $master_key );\n```\n\n### Server URL\n\nDirectly after initializing the sdk you should set the server url.\n\n```php\n// Users of Parse Server will need to point ParseClient at their remote URL and Mount Point:\nParseClient::setServerURL('https://my-parse-server.com:port','parse');\n```\n\nNotice Parse server's default port is `1337` and the second parameter `parse` is the route prefix of your parse server.\n\nFor example if your parse server's url is `http://example.com:1337/parse` then you can set the server url using the following snippet\n\n```php\nParseClient::setServerURL('https://example.com:1337','parse');\n```\n\n### Server Health Check\n\nTo verify that the server url and mount path you've provided are correct you can run a health check on your server.\n```php\n$health = ParseClient::getServerHealth();\nif($health['status'] === 200) {\n    // everything looks good!\n}\n```\nIf you wanted to analyze it further the health response may look something like this.\n```json\n{\n    \"status\"    : 200,\n    \"response\"  : {\n        \"status\" : \"ok\"\n    }\n}\n```\nThe 'status' being the http response code, and the 'response' containing what the server replies with.\nAny additional details in the reply can be found under 'response', and you can use them to check and determine the availability of parse-server before you make requests.\n\nNote that it is _not_ guaranteed that 'response' will be a parsable json array. If the response cannot be decoded it will be returned as a string instead.\n\nA couple examples of bad health responses could include an incorrect mount path, port or domain.\n```json\n// ParseClient::setServerURL('http://localhost:1337', 'not-good');\n{\n    \"status\": 404,\n    \"response\": \"\u003c!DOCTYPE html\u003e...Cannot GET \\/not-good\\/health...\"\n}\n\n// ParseClient::setServerURL('http://__uh__oh__.com', 'parse');\n{\n    \"status\": 0,\n    \"error\": 6,\n    \"error_message\": \"Couldn't resolve host '__uh__oh__.com'\"\n}\n```\nKeep in mind `error` \u0026 `error_message` may change depending on whether you are using the **curl** (may change across versions of curl) or **stream** client.\n\n### Http Clients\n\nThis SDK has the ability to change the underlying http client at your convenience.\nThe default is to use the curl http client if none is set, there is also a stream http client that can be used as well.\n\nSetting the http client can be done as follows:\n```php\n// set curl http client (default if none set)\nParseClient::setHttpClient(new ParseCurlHttpClient());\n\n// set stream http client\n// ** requires 'allow_url_fopen' to be enabled in php.ini **\nParseClient::setHttpClient(new ParseStreamHttpClient());\n```\n\nIf you have a need for an additional http client you can request one by opening an issue or by submitting a PR.\n\nIf you wish to build one yourself make sure your http client implements ```ParseHttpable``` for it be compatible with the SDK. Once you have a working http client that enhances the SDK feel free to submit it in a PR so we can look into adding it in.\n\n### Alternate CA File\n\nIt is possible that your local setup may not be able to verify with peers over SSL/TLS. This may especially be the case if you do not have control over your local installation, such as for shared hosting.\n\nIf this is the case you may need to specify a Certificate Authority bundle. You can download such a bundle from \u003ca href=\"http://curl.haxx.se/ca/cacert.pem\"\u003ehttp://curl.haxx.se/ca/cacert.pem\u003c/a\u003e to use for this purpose. This one happens to be a Mozilla CA certificate store, you don't necessarily have to use this one but it's recommended.\n\nOnce you have your bundle you can set it as follows:\n```php\n// ** Use an Absolute path for your file! **\n// holds one or more certificates to verify the peer with\nParseClient::setCAFile(__DIR__ . '/certs/cacert.pem');\n```\n\n## Getting Started\n\nWe highly recommend you read through the [guide](http://docs.parseplatform.org/php/guide/) first. This will walk you through the basics of working with this sdk, as well as provide insight into how to best develop your project.\n\nIf want to know more about what makes the php sdk tick you can read our [API Reference](http://parseplatform.org/parse-php-sdk/namespaces/parse.html) and flip through the code on [github](https://github.com/parse-community/parse-php-sdk/).\n\nCheck out the [Parse PHP Guide] for the full documentation.\n\n### Use Declarations\n\nAdd the \"use\" declarations where you'll be using the classes. For all of the\nsample code in this file:\n\n```php\nuse Parse\\ParseObject;\nuse Parse\\ParseQuery;\nuse Parse\\ParseACL;\nuse Parse\\ParsePush;\nuse Parse\\ParseUser;\nuse Parse\\ParseInstallation;\nuse Parse\\ParseException;\nuse Parse\\ParseAnalytics;\nuse Parse\\ParseFile;\nuse Parse\\ParseCloud;\nuse Parse\\ParseClient;\nuse Parse\\ParsePushStatus;\nuse Parse\\ParseServerInfo;\nuse Parse\\ParseLogs;\nuse Parse\\ParseAudience;\n```\n\n### Parse Objects\n\nParse Objects hold your data, can be saved, queried for, serialized and more!\nObjects are at the core of this sdk, they allow you to persist your data from php without having to worry about any databasing code.\n\n```php\n$object = ParseObject::create(\"TestObject\");\n$objectId = $object-\u003egetObjectId();\n$php = $object-\u003eget(\"elephant\");\n\n// Set values:\n$object-\u003eset(\"elephant\", \"php\");\n$object-\u003eset(\"today\", new DateTime());\n$object-\u003esetArray(\"mylist\", [1, 2, 3]);\n$object-\u003esetAssociativeArray(\n    \"languageTypes\", array(\"php\" =\u003e \"awesome\", \"ruby\" =\u003e \"wtf\")\n);\n\n// Save normally:\n$object-\u003esave();\n\n// Or pass true to use the master key to override ACLs when saving:\n$object-\u003esave(true);\n\n// encode an object for later use\n$encoded = $object-\u003eencode();\n\n// decode an object\n$decodedObject = ParseObject::decode($encoded);\n```\n\n### Users\n\nUsers are a special kind of object.\nThis class allows individuals to access your applications with their unique information and allows you to identify them distinctly.\nUsers may also be linked with 3rd party accounts such as facebook, twitter, etc.\n\n```php\n// Signup\n$user = new ParseUser();\n$user-\u003esetUsername(\"foo\");\n$user-\u003esetPassword(\"Q2w#4!o)df\");\ntry {\n    $user-\u003esignUp();\n} catch (ParseException $ex) {\n    // error in $ex-\u003egetMessage();\n}\n\n// Login\ntry {\n    $user = ParseUser::logIn(\"foo\", \"Q2w#4!o)df\");\n} catch(ParseException $ex) {\n    // error in $ex-\u003egetMessage();\n}\n\n// Current user\n$user = ParseUser::getCurrentUser();\n```\n#### Session Id and Session Fixation\nIn an attempt to avoid [session fixation exploits](https://www.owasp.org/index.php/Session_fixation), the PHP SDK will call [`session_regenerate_id()`](http://php.net/manual/en/function.session-regenerate-id.php) when a session's permissions are elevated (since 1.5.0).  In practice this means that `session_regenerate_id()` will be called when a session goes from no user to anonymous user or from no user / anonymous user to registered user.\n\nChanging the PHP session id should have no impact on the contents of the session and state should be maintained for a user that was anonymous and becomes registered.\n\n#### Verification Emails\n\nIf you are using email verification in your parse server setup you can request to send verification emails by hand.\n```php\nParseUser::requestVerificationEmail('email@example.com');\n```\nNote that this will only send if the account for the email requested has not already been verified.\n\n### ACLs\n\nAccess Control Lists (ACLs) allow you to granularly control access to individual Parse Objects.\nACLs allow you to configure access to the general public, roles, and individual users themselves.\n\n```php\n// Access only by the ParseUser in $user\n$userACL = ParseACL::createACLWithUser($user);\n\n// Access only by master key\n$restrictedACL = new ParseACL();\n\n// Set individual access rights\n$acl = new ParseACL();\n$acl-\u003esetPublicReadAccess(true);\n$acl-\u003esetPublicWriteAccess(false);\n$acl-\u003esetUserWriteAccess($user, true);\n$acl-\u003esetRoleWriteAccessWithName(\"PHPFans\", true);\n```\n\n### Queries\n\nQueries allow you to recall objects that you've saved to parse-server.\nQuery methods and parameters allow allow a varying degree of querying for objects, from all objects of a class to objects created within a particular date range and more.\n\n```php\n$query = new ParseQuery(\"TestObject\");\n\n// Get a specific object:\n$object = $query-\u003eget(\"anObjectId\");\n\n$query-\u003elimit(10); // default 100, max 1000\n\n// All results, normally:\n$results = $query-\u003efind();\n\n// Or pass true to use the master key to override ACLs when querying:\n$results = $query-\u003efind(true);\n\n// Just the first result:\n$first = $query-\u003efirst();\n\n// Process ALL (without limit) results with \"each\".\n// Will throw if sort, skip, or limit is used.\n$query-\u003eeach(function($obj) {\n    echo $obj-\u003egetObjectId();\n});\n\n```\n#### Aggregate\n\nQueries can be made using aggregates, allowing you to retrieve objects over a set of input values.\nKeep in mind that `_id` does not exist in parse-server. Please replace with `objectId`. MasterKey is Required\n\nFor a list of available operators please refer to Mongo Aggregate Documentation.\n\n \u003ca href=\"https://docs.mongodb.com/v3.2/reference/operator/aggregation/\"\u003eMongo 3.2 Aggregate Operators\u003c/a\u003e\n\n```php\n// group pipeline is similar to distinct, can apply $sum, $avg, $max, $min\n// accumulate sum and store in total field\n$pipeline = [\n    'group' =\u003e [\n        'objectId' =\u003e null,\n        'total' =\u003e [ '$sum' =\u003e '$score']\n    ]\n];\n$results = $query-\u003eaggregate($pipeline);\n\n// project pipeline is similar to keys, add or remove existing fields\n// includes name key\n$pipeline = [\n    'project' =\u003e [\n        'name' =\u003e 1\n    ]\n];\n$results = $query-\u003eaggregate($pipeline);\n\n// match pipeline is similar to equalTo\n// filter out objects with score greater than 15\n $pipeline = [\n    'match' =\u003e [\n        'score' =\u003e [ '$gt' =\u003e 15 ]\n    ]\n];\n$results = $query-\u003eaggregate($pipeline);\n```\n\n#### Distinct\n\nQueries can be made using distinct, allowing you find unique values for a specified field.\nKeep in mind that MasterKey is required.\n```php\n// finds score that are unique\n$results = $query-\u003edistinct('score');\n\n// can be used with equalTo\n$query = new ParseQuery('TestObject');\n$query-\u003eequalTo('name', 'foo');\n$results = $query-\u003edistinct('score');\n```\n\n#### Relative Time\n\nQueries can be made using relative time, allowing you to retrieve objects over a varying ranges of relative dates.\nKeep in mind that all relative queries are performed using the server's time and timezone.\n```php\n// greater than 2 weeks ago\n$query-\u003egreaterThanRelativeTime('createdAt', '2 weeks ago');\n\n// less than 1 day in the future\n$query-\u003elessThanRelativeTime('updatedAt', 'in 1 day');\n\n// can make queries to very specific points in time\n$query-\u003egreaterThanOrEqualToRelativeTime('createdAt', '1 year 2 weeks 30 days 2 hours 5 minutes 10 seconds ago');\n\n// can make queries based on right now\n// gets everything updated up to this point in time\n$query-\u003elessThanOrEqualToRelativeTime('updatedAt', 'now');\n\n// shorthand keywords work as well\n$query-\u003egreaterThanRelativeTime('date', '1 yr 2 wks 30 d 2 hrs 5 mins 10 secs ago');\n```\n\n### Cloud Functions\n\nDirectly call server-side cloud functions and get their results.\n\n```php\n$results = ParseCloud::run(\"aCloudFunction\", array(\"from\" =\u003e \"php\"));\n```\n\n### Cloud Jobs\n\nLike cloud functions, cloud jobs allow you to run code server-side but in an asynchronous fashion.\nInstead of waiting for execution to complete you are immediately returned an id for tracking the job's progress.\nYou can use this id to see the current information on a job and whether it has completed.\n```php\n// start job\n$jobStatusId = ParseCloud::startJob('MyCloudJob', array(\"startedBy\" =\u003e \"me!\"));\n\n// get job status, a ParseObject!\n$jobStatus = ParseCloud::getJobStatus($jobStatusId);\n$status = $jobStatus-\u003eget('status'); // failed / succeeded when done\n\n```\n\n### Config\n\n**ParseConfig** allows you to access the global **Config** object for your parse server setup.\nYou can get, set and update simple values much like you would on an instance of **ParseObject**. Through this all your SDKs and applications can have access to global settings, options, and more.\nWhat you choose to put in your config is purely up to you however.\n```php\n$config = new ParseConfig();\n\n// check a config value of yours\n$allowed = $config-\u003eget('feature_allowed');\n\n// add a simple config value\n$config-\u003eset('feature_allowed', true);\n\n// save this global config\n$config-\u003esave();\n```\n\n\n### Analytics\n\nA specialized Parse Object built purposely to make analytics easy.\n\n```php\nParseAnalytics::track(\"logoReaction\", array(\n    \"saw\" =\u003e \"elephant\",\n    \"said\" =\u003e \"cute\"\n));\n```\n\n### Files\n\nPersist files to parse-server and retrieve them at your convenience. Depending on how your server is setup there are a variety of storage options including mongodb, Amazon S3 and Google Cloud Storage. You can read more about that [here](https://github.com/parse-community/parse-server/#configuring-file-adapters).\n\n```php\n// Get from a Parse Object:\n$file = $aParseObject-\u003eget(\"aFileColumn\");\n$name = $file-\u003egetName();\n$url = $file-\u003egetURL();\n// Download the contents:\n$contents = $file-\u003egetData();\n\n// Upload from a local file:\n$file = ParseFile::createFromFile(\n    \"/tmp/foo.bar\", \"Parse.txt\", \"text/plain\"\n);\n\n// Upload from variable contents (string, binary)\n$file = ParseFile::createFromData($contents, \"Parse.txt\", \"text/plain\");\n```\n\n### Push\n\nPush notifications can be constructed and sent using this sdk. You can send pushes to predefined channels of devices, or send to a customized set of devices using the power of `ParseQuery`.\n\nIn order to use Push you must first configure a [working push configuration](http://docs.parseplatform.org/parse-server/guide/#push-notifications) in your parse server instance.\n\n#### Push to Channels\n\nYou can send push notifications to any channels that you've created for your users.\n\n```php\n$data = array(\"alert\" =\u003e \"Hi!\");\n\n// Parse Server has a few requirements:\n// - The master key is required for sending pushes, pass true as the second parameter\n// - You must set your recipients by using 'channels' or 'where', but you must not pass both\n\n\n// Push to Channels\nParsePush::send(array(\n    \"channels\" =\u003e [\"PHPFans\"],\n    \"data\" =\u003e $data\n), true);\n```\n\n#### Push with Query\n\nYou can also push to devices using queries targeting the `ParseInstallation` class.\n\n```php\n// Push to Query\n$query = ParseInstallation::query();\n$query-\u003eequalTo(\"design\", \"rad\");\n\nParsePush::send(array(\n    \"where\" =\u003e $query,\n    \"data\" =\u003e $data\n), true);\n```\n\n#### Push with Audience\n\nIf you want to keep track of your sends when using queries you can use the `ParseAudience` class.\nYou can create and configure your Audience objects with a name and query.\nWhen you indicate it's being used in a push the `lastUsed` and `timesUsed` values are updated for you.\n```php\n$iosQuery = ParseInstallation::getQuery();\n$iosQuery-\u003eequalTo(\"deviceType\", \"ios\");\n\n// create \u0026 save your audience\n$audience = ParseAudience::createAudience(\n    'MyiOSAudience',\n    $iosQuery\n);\n$audience-\u003esave(true);\n\n// send a push using the query in this audience and it's id\n// The 'audience_id' is what allows parse to update 'lastUsed' and 'timesUsed'\n// You could use any audience_id with any query and it will still update that audience\nParsePush::send([\n    'data'          =\u003e [\n        'alert' =\u003e 'hello ios users!'\n    ],\n    'where'         =\u003e $audience-\u003egetQuery(),\n    'audience_id'   =\u003e $audience-\u003egetObjectId()\n], true);\n\n// fetch changes to this audience\n$audience-\u003efetch(true);\n\n// get last \u0026 times used for tracking\n$timesUsed = $audience-\u003egetTimesUsed();\n$lastUsed = $audience-\u003egetLastUsed();\n```\nAudiences provide you with a convenient way to group your queries and keep track of how often and when you send to them.\n\n#### Push Status\n\nIf your server supports it you can extract and check the current status of your pushes.\nThis allows you to monitor the success of your pushes in real time.\n\n```php\n// Get Push Status\n$response = ParsePush::send(array(\n    \"channels\" =\u003e [\"StatusFans\"],\n    \"data\" =\u003e $data\n), true);\n\nif(ParsePush::hasStatus($response)) {\n\n    // Retrieve PushStatus object\n    $pushStatus = ParsePush::getStatus($response);\n\n    // check push status\n    if($pushStatus-\u003eisPending()) {\n        // handle a pending push request\n\n    } else if($pushStatus-\u003eisRunning()) {\n        // handle a running push request\n\n    } else if($pushStatus-\u003ehasSucceeded()) {\n        // handle a successful push request\n\n    } else if($pushStatus-\u003ehasFailed()) {\n        // handle a failed request\n\n    }\n\n    // ...or get the push status string to check yourself\n    $status = $pushStatus-\u003egetPushStatus();\n\n    // get # pushes sent\n    $sent = $pushStatus-\u003egetPushesSent();\n\n    // get # pushes failed\n    $failed = $pushStatus-\u003egetPushesFailed();\n\n}\n```\n\n### Server Info\n\nAny server version **2.1.4** or later supports access to detailed information about itself and it's capabilities.\nYou can leverage `ParseServerInfo` to check on the features and version of your server.\n\n#### Version\nGet the current version of the server you are connected to.\n\n```php\n// get the current version of the server you are connected to (2.6.5, 2.5.4, etc.)\n$version = ParseServerInfo::getVersion();\n```\n\n#### Features\nCheck which features your server has and how they are configured.\n\n```php\n// get the current version of the server you are connected to (2.6.5, 2.5.4, etc.)\n$version = ParseServerInfo::getVersion();\n\n// get various features\n$globalConfigFeatures = ParseServerInfo::getGlobalConfigFeatures();\n/**\n * Returns json of the related features\n * {\n *    \"create\" : true,\n *    \"read\"   : true,\n *    \"update\" : true,\n *    \"delete\" : true\n * }\n */\n\n // you can always get all feature data\n $data = ParseServerInfo::getFeatures();\n```\n\n You can get details on the following features as well:\n\n ```php\n ParseServerInfo::getHooksFeatures();\n ParseServerInfo::getCloudCodeFeatures();\n ParseServerInfo::getLogsFeatures();\n ParseServerInfo::getPushFeatures();\n ParseServerInfo::getSchemasFeatures();\n\n // additional features can be obtained manually using 'get'\n $feature = ParseServerInfo::get('new-feature');\n\n ```\n\n### Schema\nDirect manipulation of the classes that are on your server is possible through `ParseSchema`.\nAlthough fields and classes can be automatically generated (the latter assuming client class creation is enabled) `ParseSchema` gives you explicit control over these classes and their fields.\n```php\n// create an instance to manage your class\n$mySchema = new ParseSchema(\"MyClass\");\n\n// gets the current schema data as an associative array, for inspection\n$data = $mySchema-\u003eget();\n\n// add any # of fields, without having to create any objects\n$mySchema-\u003eaddString('string_field');\n$mySchema-\u003eaddNumber('num_field');\n$mySchema-\u003eaddBoolean('bool_field');\n$mySchema-\u003eaddDate('date_field');\n$mySchema-\u003eaddFile('file_field');\n$mySchema-\u003eaddGeoPoint('geopoint_field');\n$mySchema-\u003eaddPolygon('polygon_field');\n$mySchema-\u003eaddArray('array_field');\n$mySchema-\u003eaddObject('obj_field');\n$mySchema-\u003eaddPointer('pointer_field');\n\n// you can even setup pointer/relation fields this way\n$mySchema-\u003eaddPointer('pointer_field', 'TargetClass');\n$mySchema-\u003eaddRelation('relation_field', 'TargetClass');\n\n// new types can be added as they are available\n$mySchema-\u003eaddField('new_field', 'ANewDataType');\n\n// save/update this schema to persist your field changes\n$mySchema-\u003esave();\n// or\n$mySchema-\u003eupdate();\n\n```\nAssuming you want to remove a field you can simply call `deleteField` and `save/update` to clear it out.\n```php\n$mySchema-\u003edeleteField('string_field');\n$mySchema-\u003esave():\n// or for an existing schema...\n$mySchema-\u003eupdate():\n```\nA schema can be removed via `delete`, but it must be empty first.\n```php\n$mySchema-\u003edelete();\n```\n#### Index\nIndexes support efficient execution of queries from the database. MasterKey is required.\n```php\n// To add an index, the field must exist before you create an index\n$schema-\u003eaddString('field');\n$index = [ 'field' =\u003e 1 ];\n$schema-\u003eaddIndex('index_name', $index);\n$schema-\u003esave();\n\n// Delete an index\n$schema-\u003edeleteIndex('index_name');\n$schema-\u003esave();\n\n// If indexes exist, you can retrieve them\n$result = $schema-\u003eget();\n$indexes = $result['indexes'];\n ```\n\n#### Purge\nAll objects can be purged from a schema (class) via `purge`. But be careful! This can be considered an irreversible action.\nOnly do this if you _really_ need to delete all objects from a class, such as when you need to delete the class (as in the code example above).\n```php\n// delete all objects in the schema\n$mySchema-\u003epurge();\n```\n\n### Logs\n`ParseLogs` allows info and error logs to be retrieved from the server as JSON.\nUsing the same approach as that which is utilized in the [dashboard](https://github.com/parse-community/parse-dashboard) you can view your logs with specific ranges in time, type and order.\nNote that this requires the correct masterKey to be set during your initialization for access.\n```php\n// get last 100 info logs, sorted in descending order\n$logs = ParseLogs::getInfoLogs();\n\n// get last 100 info logs, sorted in descending order\n$logs = ParseLogs::getErrorLogs();\n\n// logs can be retrieved with further specificity\n// get 10 logs from a date up to a date in ascending order\n$logs = ParseLogs::getInfoLogs(10, $fromDate, $untilDate, 'asc');\n\n// above can be done for 'getErrorLogs' as well\n```\n\n\n## Contributing / Testing\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for information on testing and contributing to the Parse PHP SDK.\n\n-----\n\nAs of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.\n\n[Get Composer]: https://getcomposer.org/download/\n[Parse PHP Guide]: https://docs.parseplatform.org/php/guide/\n[open-collective-link]: https://opencollective.com/parse-server\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparse-community%2Fparse-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparse-community%2Fparse-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparse-community%2Fparse-php-sdk/lists"}