mrcrmn/laravel-webhooks is a Laravel package.
It currently has 3 GitHub stars and 13 downloads on Packagist (latest version 0.1.3).
Install it with composer require mrcrmn/laravel-webhooks.
Discover more Laravel packages by mrcrmn
or browse all Laravel packages to compare alternatives.
Last updated
This package allows you to add closure based handlers to GitHub or GitLab Webhooks. A 'push' handler for autodeploying is included out-of-the-box but feel free to add your own one.
Run composer require mrcrmn/laravel-webhooks.
Publish the configuration file php artisan vendor:publish --provider=mrcrmn/laravel-webhooks.
Edit the config/webhook.phpfile as needed.
If you are not using Laravels auto discovery, you need to add mrcrmn\Webhook\Provider\WebhookServiceProvider::class to the config/app.php provider array, as well as 'Webhook' => mrcrmn\Webhook\Facade\Webhook::class to the facades.
To register an event handler, you need to go to your AppServiceProvider and add the following to the boot method:
use mrcrmn\Webhook\Facade\Webhook;
Webhook::handler('push', function($request){
Artisan::call('deploy');
});
This package can run several configurable commands once a webhook hits your application. It will execute the given commands from top to bottom in the root laravel directory. If a command returns an exit code > 0, command execution will stop. All outputs will be logged by your default log driver. Make sure to check if everything went as exprected!
repositorySpecify your git repository name here. This is needed so we can verfify the integrity of the webhook request.
branchThe branch name your events should respond to.
adapterCurrently github and gitlab are supported.
uriThis is the uri that is registered in your application. Make sure you point your git providers webhook to this uri.
controllerThis is the controller that is invoked, once a request hits the uri.
middleware-nameThis is the name of the middleware group that is registered. You probably don't need to change this.
middlewareThis are the middleware that is run to verify the request. You can add your own to the array.
eventsThese are the events that your application can listen to.
By default only the push event is listened to. You can allow all events by using the * wildcard.
secretThis is important. Make sure you provide a secret when you are creating a webhook and put it in your .env file under WEBHOOK_SECRET or else anybody can post to your application and trigger event handlers.
maintenance-modeIf you are using the auto deploy feature, setting this to true runs php artisan down before the deployment commands, and php artisan up once all commands are executed.
Warning
If one of your commands returns a status code >= 1, command execution will stop and your application will stay in maintenance mode.
commandsThis is the array of commands that are executed when you push to your given branch. Feel free to remove or add your own commands. Make sure you know what you are doing!
The output of all executed commands are written to the default Log driver.