1. Go to this page and download the library: Download frnkly/laravel-keen 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/ */
frnkly / laravel-keen example snippets
return [
// Other 3rd-party Services
// ...
// Add your Keen information here
'keen' => [
'id' => env('KEEN_PROJECT_ID'),
'master' => env('KEEN_MASTER_KEY'),
'write' => env('KEEN_WRITE_KEY'),
],
];
/**
* Determines if the middleware should run or not.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Response $response
* @return bool
*/
protected function shouldRun($request, $response) : bool
{
if (! parent::shouldRun($request, $response)) {
return false;
}
// Define your own custom logic here.
// ...
return true;
}
namespace App\Events;
use App\Events\OrderShipped;
use Frnkly\LaravelKeen\Client;
class OrderShipped
{
private $client;
public function __construct(Client $client)
{
// The client can now be accessed by all methods in this class.
$this->client = $client;
}
public function handle(OrderShipped $event)
{
// By adding a deferred event, we can continue working on the request
// without waiting on a reply back from Keen.io. The event will be
// processed once the request is done–automatically and transparently.
$this->client->addDeferredEvent('order-shipped', [
// Event data...
]);
}
}
use Frnkly\LaravelKeen\Client;
class UserController extends Controller
{
public function store(Client $client)
{
$client->addDeferredEvent('new-user', [
// Event data...
]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.