PHP code example of terpise / laravel-webhook

1. Go to this page and download the library: Download terpise/laravel-webhook library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

terpise / laravel-webhook example snippets


Route::get('callback', [WebhookClientController::class, 'verify'])->middleware(VerifyToken::class);
Route::post('callback', [WebhookClientController::class, 'callback'])->middleware(VerifyToken::class);

// verify use callback authentication when registering
// callback method you can get data from webhook
// middleware for checking the authenticity of the callback, use 'verify_token'

public function verify(Request $request)
{
    return new Response(['challenge' => $request->get('challenge')]);
}


WebhookEvent::dispatch([
    "event_time" => now(),
    "event_type" => 'create',
    "object_id" => 888888,
    "object_type" => "users",
]);
bash
php artisan vendor:publish --tag=webhook-config
bash
php artisan vendor:publish --tag=webhook-migrations
bash
php artisan migrate
bash
php artisan webhook:make
bash
php artisan queue:work