---
title: Laravel
description: Send Trigv push alerts from Laravel jobs, listeners, scheduled commands, payment handlers, and webhook flows.
---
# Laravel

Send focused Trigv push alerts from a Laravel app when something important happens: a payment succeeds, a webhook fails, a queue backs up, or a scheduled command finishes.

Use this page when you want Laravel-specific setup. For the package API itself, see the [PHP SDK reference](/docs/sdks/php/).

## Install the PHP SDK

The Laravel setup uses the official `trigv/trigv` Composer package.

```
composer require trigv/trigv
```

Add your workspace API key to `.env`:

```
TRIGV_API_KEY=trgv_your_api_key
```

Then expose it through `config/services.php`:

```
'trigv' => [
		'api_key' => env('TRIGV_API_KEY'),
		'base_url' => env('TRIGV_BASE_URL', 'https://api.trigv.com/api'),
],
```

## Register the SDK client

Bind the SDK client once so jobs, listeners, controllers, and commands can receive it through Laravel's container.

```
use Illuminate\Support\ServiceProvider;
use Trigv\Client;

class AppServiceProvider extends ServiceProvider
{
		public function register(): void
		{
			$this->app->singleton(Client::class, function () {
				return new Client([
					'api_key' => config('services.trigv.api_key'),
					'base_url' => config('services.trigv.base_url'),
				]);
			});
		}
}
```

## Send from a queued job

For user-facing requests, dispatch a job and send the Trigv event in the background. That keeps checkout, form submits, and webhook responses fast.

```
use Trigv\Client;

class NotifyPaymentReceived
{
		public function __construct(
			private readonly Client $trigv,
		) {}

		public function handle(): void
		{
			$this->trigv->sendEvent([
				'channel' => 'payments',
				'title' => 'Payment received',
				'description' => 'Order #1042 was paid successfully',
				'level' => 'success',
				'event_type' => 'payment.success',
				'idempotency_key' => 'payment-1042-success',
			]);
		}
}
```

## Send from a scheduled command

Trigv works well for commands that normally disappear into logs. Send an alert only when the result matters.

```
use Illuminate\Console\Command;
use Trigv\Client;

class SyncInvoices extends Command
{
		protected $signature = 'invoices:sync';

		public function handle(Client $trigv): int
		{
			// Run your sync work...

			$trigv->sendEvent([
				'channel' => 'ops',
				'title' => 'Invoice sync finished',
				'description' => 'All billing events are up to date',
				'level' => 'success',
				'event_type' => 'invoices.sync.completed',
			]);

			return self::SUCCESS;
		}
}
```

## Good Laravel use cases

- Queue failures, stuck workers, and scheduled command results
- Payment, subscription, and billing events
- Important webhook outcomes from Stripe, Paddle, Creem, GitHub, or internal systems
- Admin-only operational alerts that do not belong in customer email

## When to use raw HTTP instead

Use the SDK when you are already in PHP or Laravel. Use the [event API](/docs/events/) or [cURL guide](/docs/learn/curl/) when you want no Composer dependency, a quick terminal test, or a custom runtime.

[PHP SDK reference →](/docs/sdks/php/) · [API reference →](/docs/events/)
