Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plesk-rest-api

PHP client (connector) for the Plesk REST API v2.

What is this?

This package is not a standalone Plesk plugin/extension in the sense Plesk itself uses the term (there is no meta.xml, no Plesk panel UI integration, no extension installer – nothing Plesk would recognize as an extension and surface in its own interface).

It is a plain PHP library (Composer package) meant to be pulled into other PHP projects to make HTTP requests against the Plesk REST API (https://<server>:8443/api/v2/...). Think of it as a thin HTTP client / SDK skeleton: it assembles requests (path, HTTP method, body), sends them via Guzzle with basic auth against the Plesk server, and returns the JSON response decoded as a PHP array.

Bottom line: it is a pure connector/client to the Plesk API – not a standalone runnable tool and not a ready-made set of business functions. Whether functionality such as "read disk usage" or "read a domain's PHP version" is available at all depends entirely on whether a matching request class exists (see below) – currently that is mostly not the case.

Structure (src/)

src/Client/Client.php                          Central client class (Guzzle wrapper, execute())
src/Client/Request/RequestInterface.php        Interface: getMethod(), getPath(), getBody()
src/Client/Request/AbstractRequest.php         Base class implementing the interface
src/Client/Request/Cli/Apache.php              POST cli/apache/call   (fully usable)
src/Client/Request/Cli/Nginx.php               POST cli/nginx/call    (fully usable)
src/Client/Request/Cli/Subscription.php        POST cli/subscription/call (fully usable)
src/Client/Request/Clients/ListClients.php     GET clients            (fully usable)
src/Client/Request/Clients/CreateNewClient.php POST clients          (fully usable)
src/Client/Request/Databases.php               Placeholder, TODO – currently buggy (path "dns" instead of "databases")
src/Client/Request/Dns.php                     Placeholder, TODO
src/Client/Request/Domains.php                 Placeholder, TODO – doesn't even implement the interface
src/Client/Request/Extensions.php              Placeholder, TODO
src/Client/Request/FtpUsers/Ftpusers.php       Placeholder, TODO
src/Client/Request/Server.php                  Placeholder, TODO

The Client class takes any RequestInterface object and executes it:

$client = new \JWeiland\PleskRestApi\Client\Client(
    'https://plesk.example.com',
    'admin',
    'secret'
);

$request = new \JWeiland\PleskRestApi\Client\Request\Clients\ListClients();
$result = $client->execute($request); // array with the decoded JSON response

For write requests (CLI calls, CreateNewClient) the body is filled via setRequestBody(array $parameters) and JSON-encoded.

Current feature coverage

Actually fully implemented and usable are only:

  • Managing clients: list all clients (GET clients), create a new client (POST clients)
  • CLI calls for apache, nginx, and subscription via the generic cli/<tool>/call endpoints of the Plesk API (e.g. to run Plesk CLI utilities such as subscription.sh, nginx, or apache control commands with arbitrary parameters)

Not implemented (only placeholder classes with // TODO: Implement classes, no HTTP method, no business logic):

  • Databases (Databases)
  • DNS (Dns)
  • Domains (Domains)
  • Extensions (Extensions)
  • FTP users (Ftpusers)
  • Server (Server)

So there are currently no ready-made functions to, for example, read disk usage, a domain's PHP version, traffic statistics, or similar server/domain metrics. The cli/*/call endpoints (Apache/Nginx/Subscription) can, in principle, forward arbitrary Plesk CLI commands with parameters, but that is still just a generic passthrough – not a dedicated, typed function for a specific use case.

Known issues in the current state

  • Databases.php incorrectly sets $path = 'dns' instead of 'databases' (copy-paste bug).
  • Domains.php does not implement RequestInterface (no extends AbstractRequest), so it cannot actually be used via Client::execute().
  • No tests, no PHPUnit setup or similar.

Usage as a dependency

Since this is a Composer package (jweiland/plesk-rest-api), it is typically pulled into another PHP project via composer require (e.g. a TYPO3 backend module, an internal admin tool, etc.) which then handles Plesk API communication through this client. On its own – without a surrounding application – the package serves no purpose.

About

API Client for the Plesk REST API

Resources

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages