PHPackages                             praxisnetau/serverpilot-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. praxisnetau/serverpilot-api

ActiveLibrary[API Development](/categories/api)

praxisnetau/serverpilot-api
===========================

A wrapper and data model for the ServerPilot API implemented in PHP.

1.0.2(9y ago)109433[2 issues](https://github.com/praxisnetau/serverpilot-api/issues)BSD-3-ClausePHPPHP &gt;=5.3.3

Since Oct 17Pushed 9y ago1 watchersCompare

[ Source](https://github.com/praxisnetau/serverpilot-api)[ Packagist](https://packagist.org/packages/praxisnetau/serverpilot-api)[ Docs](https://github.com/praxisnetau/serverpilot-api)[ RSS](/packages/praxisnetau-serverpilot-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

ServerPilot API
===============

[](#serverpilot-api)

A wrapper and data model for the [ServerPilot API](https://github.com/ServerPilot/API) implemented in PHP.

Requires
--------

[](#requires)

- PHP 5.3.3 or newer
- [curl/curl](https://github.com/php-mod/curl) 1.4 or newer
- PHP JSON extension
- an account with [ServerPilot](https://serverpilot.io) (+ valid Client ID and API Key)

Installation
------------

[](#installation)

You can install the API in your project either via Composer on the command-line:

```
composer require praxisnetau/serverpilot-api ~1.0

```

...or by adding it to your project composer.json file:

```
require: {
    "praxisnetau/serverpilot-api": "~1.0"
}
```

...followed by this command:

```
composer install

```

Usage
-----

[](#usage)

You will need to create a **Client ID** and **API Key** via your ServerPilot control panel. Once you have these, you may create an instance of the API by passing in your credentials like so:

```
use ServerPilot\ServerPilotAPI;

$api = ServerPilotAPI::inst('', '');
```

The API will throw an `Exception` if the credentials are invalid, or if it encounters any other problem, so it's a good idea to wrap your API code in a try/catch block, e.g.:

```
try {

    $api = ServerPilotAPI::inst('', '');

    $servers = $api->servers->listAll();

} catch (\Exception $e) {

    // Whoops, something went wrong!

}
```

You may also set the credentials via the config object if you like:

```
$api = ServerPilotAPI::inst();

$api->config()->set('client-id', '');
$api->config()->set('api-key', '');
```

Commands
--------

[](#commands)

The API works by routing property calls to a series of command objects. By default, these property names and methods match those given by the [ServerPilot API documentation](https://github.com/ServerPilot/API), i.e.:

```
$api->servers;   // For server commands
$api->sysusers;  // For system user commands
$api->apps;      // For app commands
$api->dbs;       // For database commands
$api->actions;   // For action status commands
```

### Servers

[](#servers)

Handles server-related operations.

```
$api->servers->listAll();
```

```
$api->servers->get('serverid');
```

```
$api->servers->create('name');
```

```
$api->servers->update('serverid', (boolean) $firewall, (boolean) $autoupdates);
```

```
$api->servers->delete('serverid');
```

### System Users

[](#system-users)

Handles operations on system users.

```
$api->sysusers->listAll();
```

```
$api->sysusers->get('sysuserid');
```

```
$api->sysusers->create('serverid', 'username', 'password');
```

```
$api->sysusers->update('sysuserid', 'newpassword');
```

```
$api->sysusers->delete('sysuserid');
```

### Apps

[](#apps)

Handles operations on apps.

```
$api->apps->listAll();
```

```
$api->apps->get('appid');
```

```
$api->apps->create('appname', 'sysuserid', 'runtime', ['domains'], ['wordpress']);
```

```
$api->apps->update('appid', 'runtime', ['domains']);
```

```
$api->apps->delete('appid');
```

### Databases

[](#databases)

Handles database-related operations.

```
$api->dbs->listAll();
```

```
$api->dbs->get('databaseid');
```

```
$api->dbs->create('appid', 'dbname', ['name' => 'username', 'password' => 'password']);
```

```
$api->dbs->update('databaseid', ['id' => 'userid', 'password' => 'newpassword']);
```

```
$api->dbs->delete('databaseid');
```

### Actions

[](#actions)

Retrieve the status of an action.

```
$api->actions->get('actionid');
```

Data Model
----------

[](#data-model)

While the API commands are powerful, it can sometimes be clumsy to issue a series of commands directly via the API. Enter the **data model**. Model objects are provided for each of the API command areas, including:

- `Action`
- `ActionStatus`
- `App`
- `Database`
- `DatabaseUser`
- `Server`
- `SystemUser`

Rather than returning decoded JSON data, the API returns either individual instances of data model classes, or arrays of data model classes (when multiple results are returned).

These model objects are *API-aware* and can be manipulated directly without making a separate call to the API. All model objects have an `update()` and a `delete()` method. For example:

```
if ($server = $api->servers->get('')) {

    $server->setFirewall(true);
    $server->setAutoUpdates(true);

    $server->update();  // apps->get('')) {

    $app->setRuntime('php7.1');

    $app->addDomain('myapp.mydomain.com');
    $app->removeDomain('myapp.anotherdomain.com');

    $app->update();  // apps->get('')) {

    $app->delete();  // getLastAction()) {

    $id     = $action->getID();      // ID of the action
    $data   = $action->getData();    // data returned by the API for the action
    $object = $action->getObject();  // data model object created for the action

}
```

If you just need the ID of the last action, you can use `getLastActionID()`:

```
$id = $api->getLastActionID();  // ID of the last action
```

You can go a step further and check the status of the action using the `getStatus`method, which returns an `ActionStatus` object:

```
if ($action = $api->getLastAction()) {

    if ($status = $action->getStatus()) {

        $id          = $status->getID();           // ID of the action status
        $status      = $status->getStatus();       // status text ('open', 'error', or 'success')
        $serverId    = $status->getServerID();     // ID of the server
        $dateCreated = $status->getDateCreated();  // timestamp of the status

        if ($status->isOpen()) {
            // The action hasn't finished yet!
        }

        if ($status->isError()) {
            // Whoops, something went wrong!
        }

        if ($status->isSuccessful()) {
            // Huzzah, it worked!
        }

    }

}
```

Alternatively, you can retrieve the status of the last action directly from the API using `getLastActionStatus()`:

```
$status = $api->getLastActionStatus();  // returns an ActionStatus object for last action
```

### DateTime Accessors

[](#datetime-accessors)

`DateTime` accessor methods are present for all properties returned as a timestamp via the API. For example:

```
if ($server = $api->servers->get('')) {

    $lastconn = $server->getLastConnected();        // returns integer timestamp
    $datetime = $server->getLastConnectedObject();  // returns DateTime object

}
```

To Do
-----

[](#to-do)

- implement paid plan SSL functionality for Apps
- expand data model to support additional functionality

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Total

3

Last Release

3449d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5d47a59cd183aa3f599c2b66dfce7c79c249c2eacb749f0ac8c38c4ca273d14?d=identicon)[PraxisNetAu](/maintainers/PraxisNetAu)

---

Top Contributors

[![colintucker](https://avatars.githubusercontent.com/u/1853705?v=4)](https://github.com/colintucker "colintucker (4 commits)")

---

Tags

phpapimodelwrapperserverpilot

### Embed Badge

![Health badge](/badges/praxisnetau-serverpilot-api/health.svg)

```
[![Health](https://phpackages.com/badges/praxisnetau-serverpilot-api/health.svg)](https://phpackages.com/packages/praxisnetau-serverpilot-api)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
