An open API service indexing awesome lists of open source software.

https://github.com/daniel15/laravel-webhooks

Easily organize and secure your webhooks and map them to Laravel events.
https://github.com/daniel15/laravel-webhooks

Last synced: 10 months ago
JSON representation

Easily organize and secure your webhooks and map them to Laravel events.

Awesome Lists containing this project

README

          

# Laravel Webhooks

This Laravel package helps you organize, secure and map webhooks to events.

### Installation

To get started, install Laravel Webhooks via the Composer package manager:

```
composer require obrignoni/webhooks
```

Next, register the Webhooks service provider in the providers array of your config/app.php configuration file:

```
Obrignoni\Webhooks\WebhooksServiceProvider::class,
```

### Why a webhooks package?

I want to...

1. integrate my applications with webhooks from multiple services.
2. keep the webhooks organized and secure.
3. map webhook events to Laravel events.

### Usage

Lets take [Github Webhooks](https://developer.github.com/webhooks/) for example.

A Github webhook payload looks like this...

```
POST /payload HTTP/1.1

Host: localhost:4567
X-Github-Delivery: 72d3162e-cc78-11e3-81ab-4c9367dc0958
User-Agent: GitHub-Hookshot/044aadd
Content-Type: application/json
Content-Length: 6615
X-GitHub-Event: issues

{
"action": "opened",
"issue": {
"url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
"number": 1347,
...
},
"repository" : {
"id": 1296269,
"full_name": "octocat/Hello-World",
"owner": {
"login": "octocat",
"id": 1,
...
},
...
},
"sender": {
"login": "octocat",
"id": 1,
...
}
}
```

Notice the `X-GitHub-Event` header contains `issues`, one of [Github Events](https://developer.github.com/webhooks/#events).

We can use an artisan command to setup a webhook for github.

```
php artisan make:webhook github
```

This will create the `App\Http\Webhooks\Github` class.

The webhook class extends a WebhookRequest which also extends a
FormRequest and adds a couple of extra configuration options.

Lets take a look at the generated class.

```php
'App\Events\SomebodyMadeACommentOnGithub',
'pull_request' => 'App\Events\SomebodySubmittedAPullRequest',
];

}
```

### Webhook Requests Extend Form Requests

You have the option of using the `authorize` and `rules` methods just like [Form Requests](https://laravel.com/docs/5.3/validation#form-request-validation).