PHP code example of groupesti / laravel-license

1. Go to this page and download the library: Download groupesti/laravel-license 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/ */

    

groupesti / laravel-license example snippets


use License\Actions\IssueLicense;
use License\Models\LicenseStatus;
use License\Models\LicenseType;

$license = app(IssueLicense::class)->execute([
    'product_id'        => $product->id,
    'edition_id'        => $edition->id,
    'license_type_id'   => LicenseType::idFor(LicenseType::SUBSCRIPTION),
    'license_status_id' => LicenseStatus::idFor(LicenseStatus::ACTIVE),
    'name'              => 'Acme Corp',
    'max_devices'       => 5,
    'valid_from'        => now(),
    'valid_until'       => now()->addYear(),
]);

$token = $license->plain_token; // signed JWT, returned once on creation

use License\Actions\ValidateLicense;

$result = app(ValidateLicense::class)->execute($token, $deviceId, [
    'ip_address' => request()->ip(),
]);
// ['valid' => true, 'result' => 'valid', 'license' => [...], 'claims' => [...], 'expires_at' => '...']

use License\Traits\HasLicenses;

class Team extends Model
{
    use HasLicenses; // $team->licenses()
}
bash
composer vendor:publish --tag=license-config
php artisan migrate
bash
php artisan license:create --product=my-app --type=subscription --online
bash
php artisan vendor:publish --tag=license-lang