Solution: Install the PDO extension for PHP: sudo apt-get install php8.1-mysql (adjust version).
SSH into your server (or use your local dev environment). Navigate to your web root:
cd /var/www/html # or your public_html folder
Clone the repo (replace [username]/[repo] with your chosen project):
git clone https://github.com/username/php-license-system.git license-system
cd license-system
| Problem | Likely Fix |
|--------|-------------|
| cURL error 60: SSL certificate | Update your CA certificates on the server or set CURLOPT_SSL_VERIFYPEER to false (only for testing). |
| 403 Forbidden on API | Your product secret is incorrect or missing. Re-check the admin panel. |
| Table not found | The migration failed. Check your database charset (use utf8mb4). |
| License works first time, then fails | The system might be locking to IP or domain. Enable “allow domain change” in product settings. |
CREATE TABLE licenses (
id INT AUTO_INCREMENT PRIMARY KEY,
license_key VARCHAR(64) UNIQUE NOT NULL,
product_id VARCHAR(50),
customer_email VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP NULL,
is_active BOOLEAN DEFAULT TRUE,
max_activations INT DEFAULT 1,
current_activations INT DEFAULT 0
);
If the project has a composer.json file: php license key system github install
composer install
If no Composer, ensure required extensions are enabled (PDO, openssl, json).
Now that the server is set up, you need your software to check the license. The GitHub repository should provide a client script. Here is a typical API Validation Endpoint.
Create a validate.php file in your project root (the protected software):
<?php header('Content-Type: application/json');if ($_SERVER['REQUEST_METHOD'] !== 'POST') http_response_code(405); exit(json_encode(['valid' => false, 'message' => 'Method not allowed'])); Solution: Install the PDO extension for PHP: sudo
$input = json_decode(file_get_contents('php://input'), true); $license_key = $input['key'] ?? null; $domain = $_SERVER['SERVER_NAME'];
if (!$license_key) exit(json_encode(['valid' => false, 'message' => 'License key required']));
// Call your central license server (the GitHub system you installed) $ch = curl_init('https://license-server.com/api/verify'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['key' => $license_key, 'domain' => $domain])); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); Clone the repo (replace [username]/[repo] with your chosen
if ($http_code === 200) $data = json_decode($response, true); if ($data['valid']) // License is good - store in session/cache session_start(); $_SESSION['license_valid'] = true; echo json_encode(['success' => true]); else echo json_encode(['error' => $data['message']]); else echo json_encode(['error' => 'License server unreachable']);
The system needs an admin to generate licenses. Often there’s a CLI command:
php bin/console user:create admin your-email@example.com
Or access the URL /install.php in your browser (remove after install for security).