Skip to content

Integration Examples

Ready-to-use example code for integrating License Manager into your applications. All examples are available on GitHub:

Available Examples

ExampleDescriptionBest For
PHPStandalone PHP scripts using cURLAny PHP application
LaravelLaravel package with service provider, middleware & Artisan commandsLaravel applications
WordPressWordPress plugin with admin UI, auto-updates & WP-CronWordPress plugins/themes
.NET / C#Console app, ASP.NET Core API & Blazor Server dashboardDesktop apps, cloud APIs, Blazor
JavaMaven project with HttpClient and interactive CLIDesktop apps, Spring Boot
PythonClient using requests library with CLI demoFlask, FastAPI, scripts
DjangoDjango app with client, middleware, commands & viewsDjango applications
Node.jsZero-dependency client, CLI demo & Express.js serverExpress, Fastify, Electron
Ruby on RailsClient, Rails controller & Rack middlewareRails applications

PHP

A standalone PHP client class that works with any PHP application. Uses cURL for HTTP requests with no framework dependencies.

Features:

  • License activation, verification, and deactivation
  • Update checking and downloading
  • Works with any PHP 7.4+ application

Quick usage:

php
require_once 'LicenseManagerExternalAPI.php';

$client = new LicenseManagerExternalAPI(
    apiKey: 'your-api-key',
    apiUrl: 'https://license.yoursite.com',
    productId: 'your-product-id'
);

// Activate
$result = $client->activate($licenseCode);

// Verify
$result = $client->verify($licenseData);

// Deactivate
$result = $client->deactivate($licenseData);

// Check for updates
$result = $client->checkUpdate($currentVersion);

View PHP example on GitHub

Laravel

A full Laravel package with service provider, middleware, Artisan commands, and configuration file.

Features:

  • Service provider with auto-discovery
  • VerifyLicense middleware for route protection
  • Artisan commands: license:activate, license:verify, license:deactivate
  • Configuration file for API credentials
  • License data caching for performance

Installation:

  1. Copy the laravel/ folder into your Laravel project
  2. Register the service provider or use auto-discovery
  3. Publish the config file:
bash
php artisan vendor:publish --tag=license-config
  1. Set your credentials in config/license.php or .env:
env
LICENSE_API_KEY=your-api-key
LICENSE_API_URL=https://license.yoursite.com
LICENSE_PRODUCT_ID=your-product-id

Middleware usage:

php
// In routes/web.php
Route::middleware('license.verify')->group(function () {
    // Protected routes
});

Artisan commands:

bash
php artisan license:activate YOUR-LICENSE-CODE
php artisan license:verify
php artisan license:deactivate

View Laravel example on GitHub

WordPress

A WordPress plugin with admin settings page, auto-update integration, and scheduled license verification.

Features:

  • Admin settings page under Settings menu
  • License activation/deactivation from WordPress admin
  • Automatic plugin/theme update checking via WordPress updates API
  • WP-Cron scheduled license verification
  • Admin notices for license status

Installation:

  1. Copy the wordpress/ folder to wp-content/plugins/
  2. Activate the plugin in WordPress admin
  3. Go to Settings > License Manager to enter your credentials
  4. Enter your license code and click Activate

Hooks for developers:

php
// Check if license is active in your plugin/theme
if (function_exists('is_license_active') && is_license_active()) {
    // Licensed features
}

View WordPress example on GitHub

.NET / C#

A shared LicenseManagerClient class with three example projects targeting .NET 8.0.

Examples included:

  • Console App - Interactive CLI, suitable for WPF, WinForms or MAUI desktop apps
  • ASP.NET Core API - Minimal API endpoints wrapping the license client
  • Blazor Server - Interactive web dashboard with Bootstrap UI

Quick usage:

csharp
using LicenseManager;

var options = new LicenseManagerOptions
{
    ServerUrl = "https://license.yoursite.com",
    ApiKey = "your-api-key",
    ApplicationUrl = "https://your-app.com",
};

using var client = new LicenseManagerClient(options);

// Activate
var result = await client.ActivateLicenseAsync("PRODUCT_ID", "LICENSE-CODE", "Client Name");

// Verify
var verify = await client.VerifyLicenseAsync("PRODUCT_ID");

// Check for updates
var update = await client.CheckForUpdateAsync("PRODUCT_ID", "1.0.0");

// Download update
var path = await client.DownloadUpdateAsync(update.UpdateId, "./updates");

View .NET example on GitHub

Java

A Maven project using Java's built-in HttpClient (Java 11+) and Jackson for JSON parsing.

Features:

  • Reusable LicenseManagerClient class
  • Interactive CLI sample application
  • Works with any Java app: desktop (Swing/JavaFX), Spring Boot, Android

Quick usage:

java
import com.licensemanager.LicenseManagerClient;
import com.licensemanager.LicenseManagerClient.Config;

var config = new Config(
    "https://license.yoursite.com",
    "your-api-key",
    "https://your-app.com"
);

try (var client = new LicenseManagerClient(config)) {
    // Activate
    var result = client.activateLicense("PRODUCT_ID", "LICENSE-CODE", "Client Name");

    // Verify
    var verify = client.verifyLicense("PRODUCT_ID");

    // Check for updates
    var update = client.checkForUpdate("PRODUCT_ID", "1.0.0");

    // Download update
    var path = client.downloadUpdate(update.updateId, "./updates", "main");
}

View Java example on GitHub

Python

A client using the requests library with an interactive CLI demo.

Features:

  • Single-file client (license_manager_client.py)
  • Interactive CLI sample application
  • Works with Django, Flask, FastAPI, or standalone scripts

Quick usage:

python
from license_manager_client import LicenseManagerClient

client = LicenseManagerClient(
    server_url="https://license.yoursite.com",
    api_key="your-api-key",
    application_url="https://your-app.com",
)

# Activate
result = client.activate_license("PRODUCT_ID", "LICENSE-CODE", "Client Name")

# Verify
result = client.verify_license("PRODUCT_ID")

# Check for updates
update = client.check_for_update("PRODUCT_ID", "1.0.0")

# Download update
path = client.download_update(update["update_id"], "./updates")

View Python example on GitHub

Django

A drop-in Django app with API client, middleware, management commands, and JSON API views.

Features:

  • Reusable Django app (license_manager/)
  • VerifyLicenseMiddleware for global license enforcement
  • @license_required decorator for per-view protection
  • Management commands: license_activate, license_verify, license_deactivate, license_status
  • JSON API views for activate/verify/deactivate/update-check
  • Django cache framework integration for verification caching

Installation:

  1. Copy the license_manager/ directory into your Django project
  2. Add to INSTALLED_APPS in settings.py:
python
INSTALLED_APPS = [
    # ...
    'license_manager',
]
  1. Configure in settings.py:
python
LICENSE_MANAGER = {
    "SERVER_URL": os.environ.get("LICENSE_MANAGER_SERVER_URL", "https://license.example.com"),
    "API_KEY": os.environ.get("LICENSE_MANAGER_API_KEY", ""),
    "PRODUCT_ID": os.environ.get("LICENSE_MANAGER_PRODUCT_ID", ""),
    "APP_URL": os.environ.get("LICENSE_MANAGER_APP_URL", "https://your-app.com"),
}

Management commands:

bash
./manage.py license_activate XXXX-XXXX-XXXX-XXXX "John Doe"
./manage.py license_verify
./manage.py license_status
./manage.py license_deactivate

Middleware (protect all routes):

python
MIDDLEWARE = [
    # ...
    'license_manager.middleware.VerifyLicenseMiddleware',
]

Decorator (protect individual views):

python
from license_manager.middleware import license_required

@license_required
def premium_feature(request):
    return JsonResponse({"message": "Premium content"})

Quick usage:

python
from license_manager.client import LicenseManagerClient

client = LicenseManagerClient()

# Activate
result = client.activate_license("XXXX-XXXX-XXXX", "John Doe")

# Verify (uses cached result when available)
result = client.verify_license()

# Quick boolean check
if client.is_licensed():
    print("License is valid")

# Check for updates
update = client.check_for_update("1.0.0")

# Download update
path = client.download_update(update["update_id"], "./updates")

View Django example on GitHub

Node.js

A zero-dependency client using built-in fetch (Node 18+) with CLI demo and Express.js server.

Features:

  • Zero external dependencies (uses built-in fetch)
  • Interactive CLI sample application
  • Express.js API server example with optional license-gating middleware

Quick usage:

javascript
const { LicenseManagerClient } = require('./license-manager-client');

const client = new LicenseManagerClient({
  serverUrl: 'https://license.yoursite.com',
  apiKey: 'your-api-key',
  applicationUrl: 'https://your-app.com',
});

// Activate
const result = await client.activateLicense('PRODUCT_ID', 'LICENSE-CODE', 'Client Name');

// Verify
const verify = await client.verifyLicense('PRODUCT_ID');

// Check for updates
const update = await client.checkForUpdate('PRODUCT_ID', '1.0.0');

// Download update
const path = await client.downloadUpdate(update.update_id, './updates');

View Node.js example on GitHub

Ruby on Rails

A standalone client using Ruby's Net::HTTP (zero dependencies), Rails controller, and Rack middleware.

Features:

  • Zero-dependency client (license_manager_client.rb)
  • Rails controller with activate/verify/deactivate/update endpoints
  • Rack middleware for license-gating with TTL-based caching

Quick usage:

ruby
require_relative "lib/license_manager_client"

client = LicenseManagerClient.new(
  server_url: "https://license.yoursite.com",
  api_key: "your-api-key",
  application_url: "https://your-app.com"
)

# Activate
result = client.activate_license("PRODUCT_ID", "LICENSE-CODE", "Client Name")

# Verify
result = client.verify_license("PRODUCT_ID")

# Check for updates
update = client.check_for_update("PRODUCT_ID", "1.0.0")

# Download update
path = client.download_update(update["update_id"], "./updates")

Rack middleware (optional license gating):

ruby
# config/application.rb
config.middleware.use LicenseMiddleware,
  product_id: ENV.fetch("LM_PRODUCT_ID"),
  cache_ttl: 300

View Rails example on GitHub

Customizing the Examples

These examples are starting points. You should customize them for your specific needs:

  1. Error handling - Add proper error handling and user-friendly messages
  2. Storage - Choose the appropriate storage method for license data (file, database, options table)
  3. Caching - Cache verification results to reduce API calls (recommended: 6-24 hours)
  4. Security - Store API keys securely (environment variables, encrypted config)
  5. UI - Build license activation forms that match your application's design

Next Steps