2017 © Pedro Peláez
 

library laravel-webhooks

Laravel package to handle Webhooks

image

jurihub/laravel-webhooks

Laravel package to handle Webhooks

  • Monday, July 10, 2017
  • by jurihub
  • Repository
  • 0 Watchers
  • 2 Stars
  • 143 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 6 Versions
  • 18 % Grown

The README.md

laravel-webhooks

Laravel package to handle Webhooks, (*1)

Installation guide

Include the page via Composer:, (*2)

composer require jurihub/laravel-webhooks

Add the Webhooks service provider to your config/app.php file in the providers array:, (*3)

Jurihub\LaravelWebhooks\WebhooksServiceProvider::class, (*4)

To use a Facade instead of injecting the class itself, add this to the aliases array in the same file:, (*5)

'Webhooks' => Jurihub\LaravelWebhooks\WebhooksFacade::class, (*6)

Publish the configuration file:, (*7)

php artisan vendor:publish --provider="Jurihub\LaravelWebhooks\WebhooksServiceProvider" --tag="config", (*8)

You certainly will want to add some endpoints, list them in the targets array in config/webhooks.php, (*9)

Launch the migrations (provided automatically by the ServiceProvider), that will create 2 new tables: webhooks and webhook_tries, (*10)

php artisan migrate, (*11)

The first attempt is sent automatically, but if you want to automatize retries, add the following schedule in your app/Console/Kernel.php file:, (*12)

$schedule->call(function () {
    \Jurihub\LaravelWebhooks\Http\Controllers\Webhooks\SenderController::retry();
})->everyMinute();

To handle incoming webhooks, create a new controller, eg. App\Http\Controllers\Webhooks\ReceiverController.php, (*13)

namespace App\Http\Controllers\Webhooks;

use Symfony\Component\HttpFoundation\Response;
use Jurihub\LaravelWebhooks\Http\Controllers\Webhooks\ReceiverController as BaseController;

class ReceiverController extends BaseController
{
    public function handleUserUpdated($data)
    {
        // handling $data here for type 'user.updated'
    }
}

And add the route to your routes/api.php file to receive the incoming webhooks. You may want to customize the endpoint, according to the targets listed in the config/app.php file., (*14)

Route::post('webhook', 'Webhooks\ReceiverController@handleWebhook');, (*15)

Activate the webhooks' sending queue:, (*16)

php artisan queue:work database --queue=webhook --tries=3, (*17)

The Versions

10/07 2017

dev-master

9999999-dev

Laravel package to handle Webhooks

  Sources   Download

MIT

The Requires

 

by Kristof Molnar, Jurihub

laravel webhook

10/07 2017

v0.1.4

0.1.4.0

Laravel package to handle Webhooks

  Sources   Download

MIT

The Requires

 

by Kristof Molnar, Jurihub

laravel webhook

01/06 2017

v0.1.3

0.1.3.0

Laravel package to handle Webhooks

  Sources   Download

MIT

The Requires

 

by Kristof Molnar, Jurihub

laravel webhook

01/06 2017

v0.1.2

0.1.2.0

Laravel package to handle Webhooks

  Sources   Download

MIT

The Requires

 

by Kristof Molnar, Jurihub

laravel webhook

01/06 2017

v0.1.1

0.1.1.0

Laravel package to handle Webhooks

  Sources   Download

MIT

The Requires

 

by Kristof Molnar, Jurihub

laravel webhook

24/05 2017

v0.1.0

0.1.0.0

Laravel package to handle Webhooks

  Sources   Download

MIT

The Requires

 

by Kristof Molnar, Jurihub

laravel webhook