PHP code example of evertharmeling / sparkcore

1. Go to this page and download the library: Download evertharmeling/sparkcore 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/ */

    

evertharmeling / sparkcore example snippets

 php


namespace MyApp\MyBundle\Stream;

use SparkCore\Stream\Event\SparkEvent;
use SparkCore\Stream\Sparkhose as BaseSparkhose;

class Sparkhose extends BaseSparkhose
{
    /**
     * {@inheritdoc}
     *
     * @param SparkEvent $event
     */
    public function enqueueEvent(SparkEvent $sparkEvent)
    {
        // do something with $sparkEvent
    }
}
 php


use MyApp\MyBundle\Stream\Sparkhose;

$sparkhose = new Sparkhose('spark_device_id', 'spark_access_token');
$sparkhose->consume();

 php


use MyApp\MyBundle\Stream\Sparkhose;

$sparkhose = new Sparkhose('spark_device_id', 'spark_access_token');
$sparkhose->setEventName('event_name');
$sparkhose->consume();

 php


use MyApp\MyBundle\Logger\MyLogger;
use MyApp\MyBundle\Stream\Sparkhose;

$logger = new MyLogger();

$sparkhose = new Sparkhose('spark_device_id', 'spark_access_token');
$sparkhose->setLogger($logger);
$sparkhose->consume();