<?php
require_once 'SunLicenseValidator.php';
try {
$validator = new SunLicenseValidator(
'YOUR-LICENSE-KEY',
YOUR_PRODUCT_ID,
'1.0.0'
);
if ($validator->validate()) {
echo "License is valid!";
// Continue with your application logic
}
} catch (Exception $e) {
die("License validation failed: " . $e->getMessage());
}
3. Using with Framework (Laravel Example)
<?php
namespace App\Services;
use Illuminate\Support\Facades\Cache;
class LicenseService
{
private $validator;
public function __construct()
{
$this->validator = new SunLicenseValidator(
config('license.key'),
config('license.product_id'),
config('license.version')
);
}
public function validateLicense()
{
// Cache result for 24 hours
return Cache::remember('license_status', 86400, function () {
return $this->validator->validate();
});
}
}