PHP code example of wensleydale / keen-io-laravel

1. Go to this page and download the library: Download wensleydale/keen-io-laravel 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/ */

    

wensleydale / keen-io-laravel example snippets


$event = ['purchase' => ['item' => 'Golden Elephant']];

Keen::addEvent('purchases', $event);

    # Add `KeenLaravelServiceProvider` to the `providers` array
    'providers' => array(
        ...
        Wensleydale\KeenLaravel\KeenLaravelServiceProvider::class,
    )

    # Add the `KeenFacade` to the `aliases` array
    'aliases' => array(
        ...
        'Keen' => Wensleydale\KeenLaravel\KeenFacade::class,
    )
    

use KeenIO\Client\KeenIOClient;

private $client;

public function __construct(KeenIOClient $client)
{
    $this->client = $client;
}

public function addEvent()
{
	$event = ['purchase' => ['item' => 'Golden Elephant']];    

	$this->client->addEvent('purchases', $event);
    
    //Or overwrite defaults
    $this->client->setProjectId('new-project-id');
}
shell
    $ php artisan vendor:publish