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 |
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
Customizing 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
