PHPackages                             justbetter/laravel-magento-webhooks - 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. justbetter/laravel-magento-webhooks

ActivePackage

justbetter/laravel-magento-webhooks
===================================

A Laravel package to listen to webhooks dispatched from mageplaza/webhooks.

2.2.0(1y ago)1227.0k↑106%11MITPHPPHP ^8.3CI passing

Since Jul 28Pushed 11mo ago3 watchersCompare

[ Source](https://github.com/justbetter/laravel-magento-webhooks)[ Packagist](https://packagist.org/packages/justbetter/laravel-magento-webhooks)[ Docs](https://github.com/justbetter/laravel-magento-webhooks)[ RSS](/packages/justbetter-laravel-magento-webhooks/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (7)Versions (9)Used By (1)

[ ![Package banner](./art/banner.svg)](https://github.com/justbetter/laravel-magento-webhooks "JustBetter")Laravel Magento Webhooks
========================

[](#laravel-magento-webhooks)

 [![Tests](https://camo.githubusercontent.com/b3622db9b1373fe696ddfb3c5a9331c2f50cc8f73ccbe4613b61b599c49d77e3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a7573746265747465722f6c61726176656c2d6d6167656e746f2d776562686f6f6b732f74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666c6174)](https://github.com/justbetter/laravel-magento-webhooks) [![Coverage](https://camo.githubusercontent.com/73673581769685574bb4b4a9f23225259607bf610ea790ff8c577ff2dc033626/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a7573746265747465722f6c61726176656c2d6d6167656e746f2d776562686f6f6b732f636f7665726167652e796d6c3f6c6162656c3d636f766572616765267374796c653d666c6174)](https://github.com/justbetter/laravel-magento-webhooks) [![Analysis](https://camo.githubusercontent.com/e175236fbc4c8fb17a0817ac5db1bc450ececf013f55e65cb1047c459e1bce80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a7573746265747465722f6c61726176656c2d6d6167656e746f2d776562686f6f6b732f616e616c7973652e796d6c3f6c6162656c3d616e616c79736973267374796c653d666c6174)](https://github.com/justbetter/laravel-magento-webhooks) [![Total downloads](https://camo.githubusercontent.com/7fbf32786295f54e667f7c135cce08bb846ef53718c03a810313038c3782bd6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a7573746265747465722f6c61726176656c2d6d6167656e746f2d776562686f6f6b733f636f6c6f723d626c7565267374796c653d666c6174)](https://github.com/justbetter/laravel-magento-webhooks)

This package has an endpoint to receive events from the [Mageplaza Webhooks](https://github.com/mageplaza/magento-2-webhook) module. It can be configured to dispatch Laravel events when a specific event in Magento has been triggered.

> Also check out our other [Laravel Magento packages](https://github.com/justbetter?q=laravel-magento)! We also have a [Magento Client](https://github.com/justbetter/laravel-magento-client) to easily connect Laravel to Magento!

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

[](#installation)

Install the composer package.

```
composer require justbetter/laravel-magento-webhooks
```

Setup
-----

[](#setup)

Publish the configuration of the package.

```
php artisan vendor:publish --provider="JustBetter\MagentoWebhooks\ServiceProvider" --tag=config
```

Run the migration for the event logs.

```
php artisan migrate
```

Configuration
-------------

[](#configuration)

The `events` array located in your configuration can be used to add events.

By default, **no middleware** is present on the webhook url. This can be changed by adding your own middleware to the `middleware` array, like authentication.

### Schedule clean up command

[](#schedule-clean-up-command)

In order to keep the database from filling up, schedule the `CleanLogsCommand` in your Kernel.

```
use JustBetter\MagentoWebhooks\Commands\CleanLogsCommand;

$schedule->command(CleanLogsCommand::class)->daily();
```

This command supports usage of a custom date. You can pass a date as a parameter which will clean logs from before this date. This date defaults to one month prior.

```
php artisan magento:webhooks:clean-logs --date="yesterday"
```

Magento Webhook Configuration
-----------------------------

[](#magento-webhook-configuration)

The following configuration can be used in order to successfully work with webhooks.

KeyValuePayload URL`http://localhost/magento/webhook`Method`POST`Content Type`application/json`You can configure the body any way you like as long as an `event` key is present. The `event` can be named anything.

```
{
    "event": "MyWebhookEvent",
    "some_key": "some_value"
}
```

Adding events
-------------

[](#adding-events)

Adding an event in Laravel can be easily done in a few steps.

### Create an event

[](#create-an-event)

Create a new event in Laravel and be sure to extend our `WebhookEvent`.

```
