swarming / buzzi-laravel
A service which wraps the functionality of the Buzzi PHPSDK for easy use within the Laravel framework.
Requires
- buzzi-io/buzzi-sdk-php: 0.1.0
- laravel/framework: ^5.4
This package is not auto-updated.
Last update: 2021-02-20 08:33:01 UTC
README
Buzzi for the PHP framework Laravel
Installation
The recommended way to install swarming/buzzi-laravel is through composer.
composer require swarming/buzzi-laravel
Lumen
In Lumen find the Register Service Providers
in your bootstrap/app.php
and register the Buzzi Service Provider.
$app->register(Buzzi\Laravel\ServiceProvider::class);
Laravel
In Laravel find the providers key in your config/app.php and register the Buzzi Service Provider.
'providers' => array( // ... Buzzi\Laravel\ServiceProvider::class, )
Find the aliases key in your config/app.php and add the Buzzi facade alias.
'aliases' => array( // ... 'Buzzi' => Buzzi\Laravel\Facade::class, )
Configuration
By default, the package uses the following environment variables to auto-configure the plugin without modification:
BUZZI_API_ID
BUZZI_API_SECRET
To customize the configuration file, publish the package configuration using Artisan.
php artisan vendor:publish
Update your settings in the generated app/config/buzzi.php
configuration file.
return [ 'api' => [ 'id' => env('BUZZI_API_ID', '<your-buzzi-api-id-here>'), 'secret' => env('BUZZI_API_SECRET', '<your-buzzi-api-secret-here>') ] ];
Usage
In order to use the Buzzi SDK for PHP within your app, you need to retrieve it from the Laravel Service Container. The following example uses the Buzzi client to send an event.
$buzzi = App::make('buzzi'); $buzzi->send('buzzi.ecommerce.test', ["message" => "Hello, World", "timestamp" => date(DATE_ATOM)]);
If the Buzzi facade is registered within the aliases
section of the application configuration, you can also use the
following technique.
Buzzi::send('buzzi.ecommerce.test', ["message" => "Hello, World", "timestamp" => date(DATE_ATOM)]);