1. Go to this page and download the library: Download hotmeteor/receiver 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/ */
hotmeteor / receiver example snippets
namespace App\Http\Controllers\Webhooks;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class WebhooksController extends Controller
{
public function store(Request $request)
{
return Receiver::driver('slack')
->receive($request)
->ok();
}
}
namespace App\Http\Controllers\Webhooks;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class WebhooksController extends Controller
{
public function store(Request $request, string $driver)
{
return Receiver::driver($driver)
->receive($request)
->ok();
}
}
namespace App\Http\Controllers\Webhooks;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Receiver\ReceivesWebhooks;
class WebhooksController extends Controller
{
use ReceivesWebhooks;
}
namespace App\Http\Controllers\Webhooks;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Receiver\Providers\Webhook;
class WebhooksController extends Controller
{
public function store(Request $request, string $driver)
{
return Receiver::driver($driver)
->receive($request)
->fallback(function(Webhook $webhook) {
// Do whatever you like here...
})
->ok();
}
}
namespace App\Http\Handlers\Stripe;
use Illuminate\Foundation\Bus\Dispatchable;
class CustomerCreated
{
use Dispatchable;
public function __construct(public string $event, public array $data)
{
}
public function handle()
{
// Your code here
}
}
namespace App\Http\Handlers\Stripe;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CustomerCreated implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public function __construct(public string $event, public array $data)
{
}
public function handle()
{
// Your code here
}
}
namespace App\Providers;
use App\Http\Receivers\MailchimpProvider;
use App\Http\Receivers\MailgunProvider;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$receiver = app('receiver');
$receiver->extend('mailchimp', function ($app) {
return new MailchimpProvider(
config('services.mailchimp.webhook_secret')
);
});
$receiver->extend('mailgun', function ($app) {
return new MailgunProvider(
config('services.mailgun.webhook_secret')
);
});
}
}
namespace Receiver\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class CustomProvider extends AbstractProvider
{
/**
* @param Request $request
* @return string
*/
public function getEvent(Request $request): string
{
return $request->input('event.name');
}
/**
* @param Request $request
* @return array
*/
public function getData(Request $request): array
{
return $request->all();
}
}
namespace Receiver\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class CustomProvider extends AbstractProvider
{
public function verify(Request $request): bool
{
// return result of verification
}
}
namespace Receiver\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class CustomProvider extends AbstractProvider
{
public function handshake(Request $request): array
{
// return result of handshake
}
}
shell
php artisan receiver:make <name>
shell
php artisan receiver:make <name> --verified
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.