Parse Bundle
Introduction
This bundle provides integration for Parse.com PHP SDK in your Symfony2 Project., (*1)
As I currently don't use other Parse.com tools, I've only implemented Push notifications. You're free to contribute to add other tools., (*2)
Changelog
1.1.0, (*3)
1.0.0, (*4)
- Allow to send push to channel or a ParseQuery
Installation
Install GpatonParseBundle
Simply run assuming you have installed composer.phar or composer binary:, (*5)
$ php composer.phar require gpaton/parse-bundle 1.1.*
Enable the bundle
Finally, enable the bundle in the kernel:, (*6)
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Gpaton\ParseBundle\GpatonParseBundle(),
);
}
Push Notifications
Setting up
First, you need to configure the bundle with the keys obtained when you've created your application on Parse.com :, (*7)
# app/config/config.yml
gpaton_parse:
app_id: APPLICATION_ID
rest_key: REST_KEY
master_key: MASTER_KEY
Usage
Then, you may send push notifications from your controller by loading the service gpaton.parse.push
and use the send
method :, (*8)
<?php
// Acme\DemoBundle\Controller\PushController
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class PushController extends Controller {
public function indexAction() {
$push = $this->get('gpaton.parse.push');
$data = ['alert' => 'Hi there !'];
$channels = ['My Channel'];
$push->send($data, $channels);
// ...
}
}
The send
method takes up to 4 arguments. First is mandatory and you must supply at least second or third argument :, (*9)
-
data array, (*10)
-
Channels array (optional), (*11)
-
ParseQuery (optional), (*12)
-
pushTime \DateTime (optional), (*13)
If you want to send your push to channel(s), just follow the previous sample.
To push to Query, you will use the createQuery
method :, (*14)
<?php
// Acme\DemoBundle\Controller\PushController
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class PushController extends Controller {
public function indexAction() {
$push = $this->get('gpaton.parse.push');
$data = ['alert' => 'Hi there !'];
$query = $push->createQuery();
$query->equalTo('foo', 'bar');
$push->send($data, null, $query);
// ...
}
}
If you want to schedule your Push in advance (2 weeks maximum due to Parse.com limitation) :, (*15)
<?php
// Acme\DemoBundle\Controller\PushController
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class PushController extends Controller {
public function indexAction() {
$push = $this->get('gpaton.parse.push');
$data = ['alert' => 'Hi there !'];
$query = $push->createQuery();
$query->equalTo('foo', 'bar');
$scheduledTime = new \DateTime();
$scheduledTime->modify('+5 days');
$push->send($data, null, $query, $scheduledTime);
// ...
}
}
License
This bundle is under GPL v2 license. See the complete license in the bundle:, (*16)
Resources/meta/LICENSE