Integration Examples
Ready-to-use example code for integrating License Manager into your applications. All examples are available on GitHub:
TIP
GitHub Repository: github.com/botble/license-manager-examples
Available Examples
| Example | Description | Best For |
|---|---|---|
| PHP | Standalone PHP scripts using cURL | Any PHP application |
| Laravel | Laravel package with service provider, middleware & Artisan commands | Laravel applications |
| WordPress | WordPress plugin with admin UI, auto-updates & WP-Cron | WordPress plugins/themes |
| .NET / C# | Console app, ASP.NET Core API & Blazor Server dashboard | Desktop apps, cloud APIs, Blazor |
| Java | Maven project with HttpClient and interactive CLI | Desktop apps, Spring Boot |
| Python | Client using requests library with CLI demo | Flask, FastAPI, scripts |
| Django | Django app with client, middleware, commands & views | Django applications |
| Node.js | Zero-dependency client, CLI demo & Express.js server | Express, Fastify, Electron |
| Ruby on Rails | Client, Rails controller & Rack middleware | Rails 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:
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);Laravel
A full Laravel package with service provider, middleware, Artisan commands, and configuration file.
Features:
- Service provider with auto-discovery
VerifyLicensemiddleware for route protection- Artisan commands:
license:activate,license:verify,license:deactivate - Configuration file for API credentials
- License data caching for performance
Installation:
- Copy the
laravel/folder into your Laravel project - Register the service provider or use auto-discovery
- Publish the config file:
php artisan vendor:publish --tag=license-config- Set your credentials in
config/license.phpor.env:
LICENSE_API_KEY=your-api-key
LICENSE_API_URL=https://license.yoursite.com
LICENSE_PRODUCT_ID=your-product-idMiddleware usage:
// In routes/web.php
Route::middleware('license.verify')->group(function () {
// Protected routes
});Artisan commands:
php artisan license:activate YOUR-LICENSE-CODE
php artisan license:verify
php artisan license:deactivateView 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:
- Copy the
wordpress/folder towp-content/plugins/ - Activate the plugin in WordPress admin
- Go to Settings > License Manager to enter your credentials
- Enter your license code and click Activate
Hooks for developers:
// 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:
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");Java
A Maven project using Java's built-in HttpClient (Java 11+) and Jackson for JSON parsing.
Features:
- Reusable
LicenseManagerClientclass - Interactive CLI sample application
- Works with any Java app: desktop (Swing/JavaFX), Spring Boot, Android
Quick usage:
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");
}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:
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")Django
A drop-in Django app with API client, middleware, management commands, and JSON API views.
Features:
- Reusable Django app (
license_manager/) VerifyLicenseMiddlewarefor global license enforcement@license_requireddecorator 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:
- Copy the
license_manager/directory into your Django project - Add to
INSTALLED_APPSinsettings.py:
INSTALLED_APPS = [
# ...
'license_manager',
]- Configure in
settings.py:
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:
./manage.py license_activate XXXX-XXXX-XXXX-XXXX "John Doe"
./manage.py license_verify
./manage.py license_status
./manage.py license_deactivateMiddleware (protect all routes):
MIDDLEWARE = [
# ...
'license_manager.middleware.VerifyLicenseMiddleware',
]Decorator (protect individual views):
from license_manager.middleware import license_required
@license_required
def premium_feature(request):
return JsonResponse({"message": "Premium content"})Quick usage:
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")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:
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:
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):
# config/application.rb
config.middleware.use LicenseMiddleware,
product_id: ENV.fetch("LM_PRODUCT_ID"),
cache_ttl: 300Customizing the Examples
These examples are starting points. You should customize them for your specific needs:
- Error handling - Add proper error handling and user-friendly messages
- Storage - Choose the appropriate storage method for license data (file, database, options table)
- Caching - Cache verification results to reduce API calls (recommended: 6-24 hours)
- Security - Store API keys securely (environment variables, encrypted config)
- UI - Build license activation forms that match your application's design
Next Steps
- Quick Start - 5-minute integration guide
- Integration Guide - Detailed implementation patterns
- API Reference - All API endpoints
- Webhooks - Real-time event notifications
