Skip to main content

Test Laravel SMS notifications without sending

To test Laravel SMS notifications without sending them, add a small custom notification channel that posts the message to Buggregator's /sms endpoint, and use it instead of the vonage channel in your local environment. Your toVonage() text then shows up in the Buggregator UI with the recipient and sender. Nothing reaches a phone, and no provider account is needed.

Steps

1. Start Buggregator

Port 8000 is the web UI and the SMS endpoint.

bash
docker run --pull always \
  -p 127.0.0.1:8000:8000 \
  ghcr.io/buggregator/server:latest

2. Add a channel that posts to Buggregator

A Laravel custom channel is a class with a send() method. This one reads the same VonageMessage your notification already builds and posts it in Vonage's field format to /sms/vonage.

php
<?php

namespace App\Notifications\Channels;

use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Http;

class BuggregatorSmsChannel
{
    public function send(object $notifiable, Notification $notification): void
    {
        $message = $notification->toVonage($notifiable);

        Http::post('http://127.0.0.1:8000/sms/vonage', [
            'api_key' => 'local',
            'api_secret' => 'local',
            'from' => $message->from ?? 'Laravel',
            'to' => $notifiable->routeNotificationFor('vonage', $notification),
            'text' => $message->content,
        ]);
    }
}

In Docker Compose, replace 127.0.0.1:8000 with the Buggregator service name, for example buggregator:8000.

3. Use it in local only

In the notification's via() method, return the class name of the custom channel when the app runs locally. Your toVonage() method stays as it is.

php
use App\Notifications\Channels\BuggregatorSmsChannel;

public function via(object $notifiable): array
{
    return app()->isLocal() ? [BuggregatorSmsChannel::class] : ['vonage'];
}

The recipient comes from routeNotificationForVonage() on your notifiable model, as with the real channel.

4. Send the notification and read it

Trigger the notification, for example a login code. Open http://127.0.0.1:8000. The SMS shows with a Vonage badge, the sender, the recipient and the text.

5. Keep apps apart

Add a project name as one more path segment, for example /sms/vonage/shop, to keep each app's messages in their own project.

Why it works

Laravel calls send() on whatever channel via() returns. The custom channel turns your VonageMessage into one HTTP POST. Any POST whose path starts with /sms goes to Buggregator's SMS module; with /sms/vonage it reads from, to and text by Vonage's field names and stores the message instead of sending it. If a field is missing, the card lists it as a warning.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you