Download the PHP package fernleafsystems/apiwrappers-serverpilot without Composer
On this page you can find all versions of the php package fernleafsystems/apiwrappers-serverpilot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fernleafsystems/apiwrappers-serverpilot
More information about fernleafsystems/apiwrappers-serverpilot
Files in fernleafsystems/apiwrappers-serverpilot
Package apiwrappers-serverpilot
Short Description ServerPilot: the best way to run PHP websites.
License MIT
Homepage https://serverpilot.io/
Informations about the package apiwrappers-serverpilot
serverpilot-php
This simple PHP API client binds to ServerPilot's RESTful API that allows you to manage ServerPilot resources. All responses return JSON objects, including errors.
Installation
You can install the bindings via Composer. Add this to your composer.json
:
...and then install
Or you can include manually:
Usage
General
- Connect
- Catch errors
- Actions
Servers
- List all servers
- Retrieve an existing server
- Connect a new server
- Update an existing server
- Remove an existing server
System users
- List all system users
- Retrieve an existing system user
- Create a new system user
- Update an existing system user
- Remove an existing system user
Apps
- List all apps
- Retrieve an existing app
- Create a new app
- Update an existing app
- Remove an existing app
Databases
- List all databases
- Retrieve an existing database
- Create a new database
- Update an existing database
- Remove an existing database
SSL
- Add custom SSL to an app
- Remove custom SSL from an app
- Enable AutoSSL for an app
- Force HTTP to HTTPS redirect for an app
Connect
With your API key
and id
from ServerPilot, set up the config values and pass them to the ServerPilot class. You may alternatively include a 'decode' => false
config value if you just want the raw JSON-encoded value returned.
From there, you can call any number of functions to manage your ServerPilot servers, apps, system users, databases, etc.
Catch errors
If there's a problem with any request a ServerPilotException
is thrown.
You can retrieve the error message with getMessage()
and the actual HTTP code with getCode()
.
Actions
Actions are a record of work done on ServerPilot resources. These can be things like the creation of an App, deploying SSL, deleting an old Database, etc.
All methods that modify a resource will return an actionid
which can be used to track the status of said action.
Possible values of an action status
Status | Description |
---|---|
open |
Action has not completed yet. |
success |
Action was completed successfully. |
error |
Action has completed but there were errors. |
Servers
List all servers
Retrieve an existing server
Connect a new server
Use this method to tell ServerPilot that you plan to connect a new server.
When the request goes through successfully you should get this returned:
With data.id
and data.apikey
you can run the serverpilot installer on the server you just registered.
Update an existing server
There are 2 options you can change on each server; firewall and auto updates.
Both of these options are booleans
(if you don't want to change an option you can define it as null
.
Remove an existing server
System users
List all system users
Retrieve an existing system user
Create a new system user
Parameters
Name | Type | Description |
---|---|---|
serverid |
string |
Required. The id of the Server. |
name |
string |
Required. The name of the System User. Length must be between 3 and 32 characters. Characters can be of lowercase ascii letters, digits, or a dash ('abcdefghijklmnopqrstuvwxyz0123456789-'), but must start with a lowercase ascii letter. user-32 is a valid name, while 3po is not. |
password |
string |
The password of the System User. If user has no password, they will not be able to log in with a password. No leading or trailing whitespace is allowed and the password must be at least 8 and no more than 200 characters long. |
When the request goes through successfully you should get this returned:
Update an existing system user
Parameters
Name | Type | Description |
---|---|---|
sysuserid |
string |
Required. The id of the System User. |
password |
string |
The password of the System User. If user has no password, they will not be able to log in with a password. No leading or trailing whitespace is allowed and the password must be at least 8 and no more than 200 characters long. |
Every parameter except for app id is optional (meaning that by providing null
nothing will be changed).
Remove an existing system user
Apps
List all apps
Retrieve an existing app
Create a new app
Parameters
Name | Type | Description |
---|---|---|
name |
string |
Required. The nickname of the App. Length must be between 3 and 30 characters. Characters can be of lowercase ascii letters and digits. |
sysuserid |
string |
Required. The System User that will "own" this App. Since every System User is specific to a Server, this implicitly determines on which Server the App will be created. |
runtime |
string |
Required. The PHP runtime for an App. Choose from php5.4 , php5.5 , php5.6 , php7.0 , or php7.1 . |
domains |
array |
An array of domains that will be used in the webserver's configuration. If you set your app's domain name to example.com, Nginx and Apache will be configured to listen for both example.com and www.example.com. Note: The complete list of domains must be included in every update to this field. |
wordpress |
array |
An array containing the following keys: site_title , admin_user , admin_password , and admin_email |
When the request goes through successfully you should get this returned:
Update an existing app
Parameters
Name | Type | Description |
---|---|---|
runtime |
string |
The PHP runtime for an App. Choose from php5.4 , php5.5 , php5.6 , php7.0 , or php7.1 . |
domains |
array |
An array of domains that will be used in the webserver's configuration. If you set your app's domain name to example.com, Nginx and Apache will be configured to listen for both example.com and www.example.com. Note: The complete list of domains must be included in every update to this field. |
Every parameter except for app id is optional (meaning that by providing null
nothing will be changed).
Remove an existing app
Databases
List all databases
Retrieve an existing database
Create a new database
Parameters
Name | Type | Description |
---|---|---|
appid |
string |
Required. The id of the App. |
name |
string |
Required. The name of the database. Length must be between 3 and 64 characters. Characters can be of lowercase ascii letters, digits, or a dash ('abcdefghijklmnopqrstuvwxyz0123456789-'). |
username |
string |
Required. The name of the Database User. Length must be at most 16 characters. |
password |
string |
Required. The password of the Database User. No leading or trailing whitespace is allowed and the password must be at least 8 and no more than 200 characters long. |
When the request goes through successfully you should get this returned:
Update an existing database
Parameters
Name | Type | Description |
---|---|---|
appid |
string |
Required. The id of the App. |
userid |
string |
Required. The id of the Database User. |
password |
string |
Required. The new password of the Database User. No leading or trailing whitespace is allowed and the password must be at least 8 and no more than 200 characters long. |
Every parameter except for app id is optional (meaning that by providing null
nothing will be changed).
Remove an existing database
SSL
Add custom SSL to an app
Parameters
Name | Type | Description |
---|---|---|
appid |
string |
Required. The id of the App. |
key |
string |
Required. The contents of the private key. |
cert |
string |
Required. The contents of the certificate. |
cacerts |
string |
The contents of the CA certificate(s). If none, null is acceptable. |
Remove custom SSL from an app
Enable AutoSSL for an app
AutoSSL can only be enabled when an AutoSSL certificate is available for an app.
Additionally, AutoSSL cannot be enabled when an app currently has a custom SSL certificate. To enable AutoSSL when an app is already using a custom SSL, first delete the app's custom SSL certificate.
Note that disabling AutoSSL is not done through this API call but instead is done by deleting SSL from the app.
Force SSL redirect for an app
orceSSL can only be enabled when an app already has SSL enabled.
You cannot enable ForceSSL at the same time as adding a custom SSL certificate or enabling AutoSSL.
Notes
ServerPilot site: https://serverpilot.io/
ServerPilot's API doc: https://github.com/ServerPilot/API
This project's Packagist link: https://packagist.org/packages/daverogers/serverpilot-php
Getting started with Composer: https://getcomposer.org/doc/00-intro.md
If this isn't your style, check out James West's PHP lib here: https://github.com/jameswestnz/ServerPilot-API-PHP-Wrapper
All versions of apiwrappers-serverpilot with dependencies
ext-curl Version *
ext-json Version *