PHP library wrapping the CloudLinux Licensing API (REST + XML-RPC). Manages IP licenses, Imunify keys, and KernelCare keys for the Detain\Cloudlinux\Cloudlinux class in src/Cloudlinux.php.
composer install
vendor/bin/phpunit tests/ -v
phpdbg -qrr vendor/bin/phpunit tests/ -v --coverage-clover coverage.xml --whitelist src/- Class:
Detain\Cloudlinux\Cloudlinux→src/Cloudlinux.php· PSR-4 autoload - REST base:
https://cln.cloudlinux.com/api/viagetcurlpage()+CURLOPT_*options in$restOptions - XML-RPC base:
https://cln.cloudlinux.com/clweb/xmlrpcviapear/xml_rpc2$xmlClient - Auth:
authToken()→login|timestamp|sha1(key.timestamp)— appended as&token=on REST calls - Dispatch pattern:
$apiType('rest'default or'xml') controls which backend each public method calls - Logging:
log()delegates tomyadmin_log()if available — safe to call without MyAdmin - StatisticClient:
getcurlpage()optionally reports to workerman stats ifStatisticClient.phpis present - IDE config:
.idea/— PhpStorm project settings:inspectionProfiles/(code inspection rules),cloudlinux-licensing.iml(module definition),deployment.xml(server deployment mappings)
| Public method | REST endpoint | XML-RPC method |
|---|---|---|
check($ip) |
ipl/check.json |
— |
isLicensed($ip) |
→ check() |
→ xmlIsLicensed() |
register($ip, $type) |
ipl/register.json |
— |
remove($ip, $type) |
ipl/remove.json |
→ removeLicense() |
licenseList() |
→ restList() |
→ reconcile() |
types() |
v2/ip-license/licenses/types |
— |
imunifyCreate($code, $limit) |
im/key/create.json |
— |
kcareList() |
kcare/key/list.json |
— |
tests/CloudlinuxTest.php— PHPUnit tests, requires live API credentialssetUp()loads environment variables and instantiates$this->object- Helper methods without
testprefix (e.g.Check(),ListRestResponse()) are assertion helpers called from test methods, not standalone tests - XML-RPC exception paths tested by passing
'BAD_KEY'to triggercatch(\Exception $e)blocks
# Run a single test method by name
vendor/bin/phpunit tests/ -v --filter testCheck- New REST methods: call
$this->getcurlpage($this->restUrl.'endpoint.json?token='.$this->authToken().'¶m='.urlencode($val)), decode withjson_decode($this->response, true), return the result array - New XML-RPC methods: wrap
$this->xmlClient->method_name(...)intry/catch, call$this->log('error', ...)on exception, returnfalseon failure - Dual-dispatch: add a public router method that checks
$this->apiType == 'rest'and delegates to the appropriate private method - Coding style: tabs for indentation,
camelCaseproperties and parameters (enforced by.scrutinizer.yml) - No direct
$_GET/$_POST— this is a library, not a web endpoint - Token never stored; regenerated fresh per-request via
authToken()
// Instantiate and call REST or XML-RPC backend
$client = new Detain\Cloudlinux\Cloudlinux('mylogin', 'myapikey');
$result = $client->check('192.168.1.100');
// Switch to XML-RPC backend
$client->apiType = 'xml';
$licensed = $client->isLicensed('192.168.1.100');Run caliber refresh before creating git commits to keep docs in sync with code changes.
After it completes, stage any modified doc files before committing:
caliber refresh && git add CLAUDE.md .claude/ .cursor/ .github/copilot-instructions.md AGENTS.md CALIBER_LEARNINGS.md 2>/dev/nullRead CALIBER_LEARNINGS.md for patterns and anti-patterns learned from previous sessions.
These are auto-extracted from real tool usage — treat them as project-specific rules.