Laravel Quickstart

Protect your Laravel application with license validation middleware and facades.

5 minute setup
$ composer require traffic-orchestrator/laravel
1

Install the SDK

Add the Traffic Orchestrator Laravel package via Composer.

bash
composer require traffic-orchestrator/laravel
2

Publish Config & Set Up

Publish the configuration file and add your API credentials.

bash
# Publish config
php artisan vendor:publish --tag=traffic-orchestrator-config

# Add to .env
# TRAFFIC_ORCHESTRATOR_URL=https://api.trafficorchestrator.com/api/v1
# TRAFFIC_ORCHESTRATOR_KEY=your-api-key
3

Validate with Middleware

Protect routes with the built-in license middleware.

php
// routes/web.php
Route::middleware(['license:pro'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index']);
    Route::get('/analytics', [AnalyticsController::class, 'index']);
});

// Or use the Facade anywhere
use TrafficOrchestrator\Facades\License;

$result = License::validate('TO-XXXX-XXXX-XXXX', request()->getHost());

if ($result->valid) {
    // Licensed — enable features
    $features = $result->features;
}
4

Blade Directives

Gate content in Blade templates with custom directives.

php
{{-- In any Blade template --}}

@licensed
    <!-- Shown only to licensed users -->
    <div class="pro-features">
        <h2>Pro Dashboard</h2>
        <analytics-widget />
    </div>
@else
    <div class="upgrade-prompt">
        <h2>Upgrade to Pro</h2>
        <a href="/pricing">View Plans</a>
    </div>
@endlicensed

{{-- Feature-specific gating --}}
@feature('analytics')
    <analytics-dashboard />
@endfeature