PHP code example of nanorocks / laravel-license-manager

1. Go to this page and download the library: Download nanorocks/laravel-license-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nanorocks / laravel-license-manager example snippets


return [
    'key_length' => 16,
    'default_expiration_days' => 30,
    'table_name' => 'plugin_database_newsletter_licenses',
];

use Nanorocks\LicenseManager\Services\LicenseService;

$service = app(LicenseService::class);

// Generate a license
$license = $service->createLicense([
    'license_key' => 'TEST-1234',
    'assigned_to' => '[email protected]',
    'expires_at' => now()->addDays(30),
]);

// Validate a license
$isValid = $service->validateLicense('TEST-1234');

// Assign a license to a user
$service->assignLicense('TEST-1234', '[email protected]');

// Deactivate a license
$service->deactivateLicense('TEST-1234');

use Nanorocks\LicenseManager\Facades\LicenseManager;

$isValid = LicenseManager::validateLicense('TEST-1234');
LicenseManager::assignLicense('TEST-1234', '[email protected]');
bash
php artisan vendor:publish --tag="laravel-license-manager-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-license-manager-config"
bash
php artisan license:generate --assigned-to="[email protected]" --expires-in=30 --key-length=16