Laravel SDK

subdomainto/laravel supports Laravel 12 and 13 on PHP 8.2+. It registers the client, provides a facade, publishes configuration, and adds webhook middleware.

Installation

BASH
composer require subdomainto/laravel
php artisan vendor:publish --tag=subdomainto-config
DOTENV
SUBDOMAINTO_API_KEY=sdt_live_xxxxxxxxxxxxxxxxxxxxxxxx
SUBDOMAINTO_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxx
SUBDOMAINTO_WEBHOOK_TOLERANCE=300

SUBDOMAINTO_BASE_URI is optional and defaults to the production API.

Inject the client

PHP
use SubdomainTo\Client;
use SubdomainTo\Model\Domain;

final class ConnectCustomerDomain
{
    public function __construct(private Client $subdomainTo) {}

    public function handle(string $customerId, string $domain): Domain
    {
        return $this->subdomainTo->domains()->create($domain, $customerId.'-domain');
    }
}

Use the facade

PHP
use SubdomainTo\Laravel\Facade\SubdomainTo;

$domains = SubdomainTo::domains()->list();
$usage = SubdomainTo::usage()->get();

Prefer dependency injection in business services. The facade is convenient in commands, jobs, and prototypes.

Protect a webhook route

PHP
use Illuminate\Support\Facades\Route;

Route::post('/webhooks/subdomainto', SubdomainToWebhookController::class)
    ->middleware('subdomainto.webhook');

The verified event is available at $request->attributes->get('subdomainto_event'). The middleware uses the raw body, verifies SubdomainTo-Signature, and returns 400 for an invalid signature, timestamp, or payload.

Published configuration

config/subdomainto.php exposes api_key, base_uri, webhook_secret, and webhook_tolerance. Keep secrets in the environment, never directly in this file.