PHP code example of corevisys / laravel-license-client

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

    

corevisys / laravel-license-client example snippets


use CoreVisys\License\Facades\CoreVisysLicense;

$result = CoreVisysLicense::activate($licenseKeyFromUserInput);

if ($result->success) {
    // $result->status is a LicenseStatus DTO
} else {
    // $result->message, $result->errorCode
}

'ui' => [
    'enabled' => env('COREVISYS_LICENSE_UI_ENABLED', true),
    'route_prefix' => env('COREVISYS_LICENSE_UI_PREFIX', 'license'), // -> /license/activate
    'route_name' => 'corevisys.license.activate',
    'middleware' => ['web'], // add 'auth' here to restrict to logged-in admins
],

use CoreVisys\License\Facades\CoreVisysLicense;

CoreVisysLicense::isValid();       // bool
CoreVisysLicense::isActive();
CoreVisysLicense::isExpired();
CoreVisysLicense::isRevoked();
CoreVisysLicense::isSuspended();
CoreVisysLicense::expiresAt();     // ?Carbon
CoreVisysLicense::daysRemaining(); // ?int
CoreVisysLicense::feature('reports'); // bool
CoreVisysLicense::features();      // array
CoreVisysLicense::status();        // ?LicenseStatus (last resolved)
CoreVisysLicense::fingerprint();   // string
CoreVisysLicense::licenseKey();    // ?string (decrypted from cache, or config)

// Force a fresh online check instead of using the cached/interval-gated result:
$status = CoreVisysLicense::check(force: true);

use CoreVisys\License\Contracts\LicenseClientInterface;

public function __construct(private LicenseClientInterface $license) {}

use Illuminate\Support\Facades\Route;

Route::middleware('corevisys.license')->group(function () {
    Route::get('/dashboard', DashboardController::class);
});

Route::middleware('corevisys.feature:reports')->group(function () {
    Route::get('/reports', ReportsController::class);
});

use Illuminate\Support\Facades\Schedule;

Schedule::command('corevisys:license:check')->daily();

use CoreVisys\License\Exceptions\{
    InvalidLicenseException,
    LicenseExpiredException,
    LicenseRevokedException,
    LicenseSuspendedException,
    LicenseServerUnavailableException,
    SignatureVerificationException,
    FingerprintMismatchException,
    ActivationLimitExceededException,
};

try {
    // ...
} catch (LicenseServerUnavailableException $e) {
    // $e->isRetryable() === true
    report($e);
}

CoreVisysLicense::deactivate(); // bool
bash
composer corevisys:license:install
php artisan migrate
bash
php artisan corevisys:license:activate
# or activate a specific key:
php artisan corevisys:license:activate "XXXX-XXXX-XXXX-XXXX"
bash
php artisan vendor:publish --tag=corevisys-license-views
# edit resources/views/vendor/corevisys-license/activate.blade.php
bash
php artisan corevisys:license:deactivate

src/
    CoreVisysServiceProvider.php
    Facades/CoreVisysLicense.php
    Contracts/{LicenseClientInterface,LicenseStorageInterface}.php
    Services/
        LicenseClient.php          # orchestrator behind the facade
        LicenseActivator.php       # POST /license/activate
        LicenseVerifier.php        # POST /license/check + offline fallback
        LicenseHeartbeat.php       # POST /license/pulse
        FingerprintGenerator.php
        SignedPayloadVerifier.php  # RSA-SHA256 signature checks
        LicenseStorage.php         # database or cache-store backend
        ApiRequestHandler.php      # shared HTTP transport (timeouts, retry/backoff, status handling)
    Middleware/{EnsureValidLicense,EnsureLicenseFeature}.php
    Commands/License{Install,Activate,Check,Deactivate,Status,ClearCache}Command.php
    Http/Controllers/LicenseActivationController.php  # built-in web activation screen
    DTOs/{LicenseResponse,LicenseStatus,ActivationResult}.php
    Exceptions/  (8 typed exceptions, all extending LicenseClientException)
    Events/      (10 lifecycle events)
config/corevisys-license.php
database/migrations/create_corevisys_license_cache_table.php
resources/lang/en/license.php
resources/views/activate.blade.php  # publishable via corevisys-license-views
tests/{Feature,Unit,Concerns}