PHPackages                             stichoza/jira-webhooks-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. stichoza/jira-webhooks-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stichoza/jira-webhooks-laravel
==============================

Laravel package for interacting with Jira Webhooks

v1.2.8(8mo ago)03491MITPHPPHP ^8.2

Since Jul 24Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/Stichoza/jira-webhooks-laravel)[ Packagist](https://packagist.org/packages/stichoza/jira-webhooks-laravel)[ Fund](https://btc.com/bc1qc25j4x7yahghm8nnn6lypnw59nptylsw32nkfl)[ Fund](https://www.paypal.me/stichoza)[ RSS](/packages/stichoza-jira-webhooks-laravel/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (13)Used By (0)

Jira Webhooks Laravel
=====================

[](#jira-webhooks-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/9d073da5680373ddffcbc704d43d84a1aa1457bc0bef9f391ccde3caca01dc99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f53746963686f7a612f6a6972612d776562686f6f6b732d6c61726176656c2e737667)](https://packagist.org/packages/stichoza/jira-webhooks-laravel) [![Total Downloads](https://camo.githubusercontent.com/b6eda19be782ca988e8af072ceebda88ebdf5b31f4c68db5715acb4e2a62ba1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f53746963686f7a612f6a6972612d776562686f6f6b732d6c61726176656c2e737667)](https://packagist.org/packages/stichoza/jira-webhooks-laravel) [![Downloads Month](https://camo.githubusercontent.com/b9b66a093806a65dfbe1d56da32c5946773cca9c2fd5d4af60a60fe764830fac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f53746963686f7a612f6a6972612d776562686f6f6b732d6c61726176656c2e737667)](https://packagist.org/packages/stichoza/jira-webhooks-laravel) [![Petreon donation](https://camo.githubusercontent.com/3566813b4190b2759b0439c2147228bec3a5a0f1ec6b7e0302305802431a7c3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d6f72616e67652e737667)](https://www.patreon.com/stichoza) [![PayPal donation](https://camo.githubusercontent.com/b48a7f9ca978349b83c641e4901221d7e84374bcb3300a43f739835cf930e802/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617970616c2d646f6e6174652d626c75652e737667)](https://paypal.me/stichoza)

Laravel package for interacting with Jira Webhooks.

Installation
------------

[](#installation)

Install this package via Composer:

```
composer require stichoza/jira-webhooks-laravel
```

This package uses Laravel's package auto-discovery, so you don't have to manually add the service provider.

### Laravel Without Auto-discovery

[](#laravel-without-auto-discovery)

If you don't use auto-discovery, add the ServiceProvider to the providers array in `config/app.php`

```
Stichoza\JiraWebhooksLaravel\JiraWebhooksLaravelServiceProvider::class,
```

If you want to use facade for routes, add this to aliases in you `config/app.php`

```
'JiraWebhooks' => Stichoza\JiraWebhooksLaravel\JiraWebhooks::class,
```

### Export Configuration Files

[](#export-configuration-files)

*(Optional)* If you want to customize events dispatched by the package, copy the package config to your local config with the publish command:

```
php artisan vendor:publish --provider="Stichoza\JiraWebhooksLaravel\JiraWebhooksLaravelServiceProvider" --tag=config
```

### Add Webhook Route

[](#add-webhook-route)

You can add webhook route to your routes file using `JiraWebhooks` class:

```
JiraWebhooks::route();
```

This will create a POST route with URI `jira-webhook`. You can also customize the URI of the route by passing a parameter. This method returns `Illuminate\Routing\Route` object, so you can use all other methods available on regular routes.

```
JiraWebhooks::route('jira/my_webhook')->middleware(SomeMiddleware::class);
```

### CSRF Protection

[](#csrf-protection)

If you're adding the route to your web routes, make sure you disable the CSRF middleware for the webhook route. Do this by adding URI to `$except` property of `VerifyCsrfToken` middleware.

```
protected $except = [
    // ...
    'jira-webhook', // or the custom URI you passed to `JiraWebhooks::route()`
];
```

Usage
-----

[](#usage)

By default, the package will dispatch `Stichoza\JiraWebhooksLaravel\Events\JiraWebhookReceived` event for any incoming webhook along with a specific event depending on the `webhookEvent` of webhook received.

### Using Events

[](#using-events)

Here is the table of Jira `webhookEvent` event names and respective events dispatched by this package:

Jira event nameEvent dispatched by this package\* (any webhook)`JiraWebhookReceived`jira:issue\_created`JiraWebhookJiraIssueCreated`jira:issue\_updated`JiraWebhookJiraIssueUpdated`jira:issue\_deleted`JiraWebhookJiraIssueDeleted`jira:worklog\_updated`JiraWebhookJiraWorklogUpdated`issuelink\_created`JiraWebhookIssueLinkCreated`issuelink\_deleted`JiraWebhookIssueLinkDeleted`worklog\_created`JiraWebhookWorklogCreated`worklog\_updated`JiraWebhookWorklogUpdated`worklog\_deleted`JiraWebhookWorklogDeleted`comment\_created`JiraWebhookCommentCreated`comment\_updated`JiraWebhookCommentUpdated`comment\_deleted`JiraWebhookCommentDeleted`project\_created`JiraWebhookProjectCreated`project\_updated`JiraWebhookProjectUpdated`project\_deleted`JiraWebhookProjectDeleted`jira:version\_released`JiraWebhookJiraVersionReleased`jira:version\_unreleased`JiraWebhookJiraVersionUnreleased`jira:version\_created`JiraWebhookJiraVersionCreated`jira:version\_moved`JiraWebhookJiraVersionMoved`jira:version\_updated`JiraWebhookJiraVersionUpdated`jira:version\_deleted`JiraWebhookJiraVersionDeleted`user\_created`JiraWebhookUserCreated`user\_updated`JiraWebhookUserUpdated`user\_deleted`JiraWebhookUserDeleted`option\_voting\_changed`JiraWebhookOptionVotingChanged`option\_watching\_changed`JiraWebhookOptionWatchingChanged`option\_unassigned\_issues\_changed`JiraWebhookOptionUnassignedIssuesChanged`option\_subtasks\_changed`JiraWebhookOptionSubtasksChanged`option\_attachments\_changed`JiraWebhookOptionAttachmentsChanged`option\_issuelinks\_changed`JiraWebhookOptionIssueLinksChanged`option\_timetracking\_changed`JiraWebhookOptionTimeTrackingChanged`sprint\_created`JiraWebhookSprintCreated`sprint\_deleted`JiraWebhookSprintDeleted`sprint\_updated`JiraWebhookSprintUpdated`sprint\_started`JiraWebhookSprintStarted`sprint\_closed`JiraWebhookSprintClosed`board\_created`JiraWebhookBoardCreated`board\_updated`JiraWebhookBoardUpdated`board\_deleted`JiraWebhookBoardDeleted`board\_configuration\_changed`JiraWebhookBoardConfigurationChanged`Note

Default events are in `Stichoza\JiraWebhooksLaravel\Events` namespace.

### Defining Custom Events

[](#defining-custom-events)

You can extend or customize event map by adding different events in `config/jira-webhooks.php` file. These are regular events that you can create by `php artisan make:event` command.

```
'events' => [
    // '*' => \Stichoza\JiraWebhooksLaravel\Events\JiraWebhookReceived::class,
    'jira:issue_created' => \App\Events\JiraIssueCreated::class,
    'jira:issue_updated' => \App\Events\JiraIssueUpdated::class,
    'comment_created' => \App\Events\JiraCommentCreated::class,
    'issuelink_*' => \App\Events\JiraIssueLinkCreatedOrDeleted::class,
    // ...
],
```

All events will receive the `Stichoza\JiraWebhooksData\Models\JiraWebhookData` object in the constructor.

The keys are checked against Jira's webhook event name (webhookEvent property) using `Str::is()` method, so you can use wildcards in names. You can find the full list of [Jira webhook event names here](https://developer.atlassian.com/server/jira/platform/webhooks/#registering-events-for-a-webhook).

Important

All events matching the pattern will be triggered, not just the first one.

### Handling Events

[](#handling-events)

You should define the listeners for the events that you configured in `config/jira-webhooks.php` file. You can create listeners using Laravel's `php artisan make:listener` command.

All events will have a `webhook` property of type `Stichoza\JiraWebhooksData\Models\JiraWebhookData`. This object contains all data from webhook request. Read more about these data structures in the readme of [stichoza/jira-webhooks-data](https://github.com/Stichoza/jira-webhooks-data) package.

Example
-------

[](#example)

```
