$response = file_get_contents("https://your-server.com/api/validate.php?license_key=$licenseKey&domain=$domain"); $data = json_decode($response, true);
While PHP can’t be fully hidden, use tools like or SourceGuardian for commercial apps, or at least encode critical validation logic.
Best for : Developers who want a turnkey license server with a graphical interface and integrated payment handling.
Most GitHub repositories implement variations of these components. They can be broadly categorized into self-hosted, API-based, and hybrid solutions.
If you want to avoid "reinventing the wheel" for a commercial product, experts often recommend using specialized "Licensing as a Service" (LaaS) providers like Cryptolens or Keygen , as they offer advanced features like offline licensing and piracy protection out of the box. AI responses may include mistakes. Learn more
: It provides a full REST API and wrapper libraries, allowing you to create and manage keys with ease.
For private repositories, you can use the GitHub Releases API. When a client code validates its license key, your server can temporarily generate a GitHub personal access token or download proxy link to fetch the latest .zip file archive of your software. Security Best Practices
$licenseKey = $_GET['license_key'] ?? null; $domain = $_GET['domain'] ?? null;
// License is valid – continue with your application.
Remember that any license check can be removed by a skilled user if they have access to your PHP source code. For stronger protection, consider:
While building a custom system from scratch is possible, the PHP community on GitHub offers numerous open-source solutions ranging from simple key generators to full-featured licensing servers.
[ 'status' => 'active', 'expires' => '2027-12-31', 'max_activations' => 3, 'current_activations' => 1 ] ]; $license_key = $_POST['license_key'] ?? ''; $domain = $_POST['domain'] ?? ''; if (empty($license_key) || empty($domain)) echo json_encode(['success' => false, 'message' => 'Missing parameters.']); exit; if (!isset($licenses[$license_key])) echo json_encode(['success' => false, 'message' => 'Invalid license key.']); exit; $license = $licenses[$license_key]; if ($license['status'] !== 'active' || strtotime($license['expires']) < time()) echo json_encode(['success' => false, 'message' => 'License has expired or is inactive.']); exit; if ($license['current_activations'] >= $license['max_activations']) echo json_encode(['success' => false, 'message' => 'Activation limit reached.']); exit; // Success: In a real app, save the domain activation to your database here echo json_encode([ 'success' => true, 'message' => 'License activated successfully.', 'expires' => $license['expires'] ]); Use code with caution. Step 2: Implementing the Client-Side Verification
Bind a license key to a specific domain or device to prevent sharing. For web apps, domain locking restricts the key's validity to a pre-approved URL. For desktop software, use HWID or fingerprinting. The SARA system is a good example of a license system that allows for domain, IP address, and time locking. The Laravel Licensing package includes explicit seat management functionality for handling multiple devices, which can be implemented by registering a unique device fingerprint hash.
