PHPackages                             mastercraft/aapanel-php-sdk - 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. mastercraft/aapanel-php-sdk

ActiveLibrary[API Development](/categories/api)

mastercraft/aapanel-php-sdk
===========================

PHP SDK for aaPanel API

v1.0.0-alpha-1(1y ago)0141[1 issues](https://github.com/IAmMasterCraft/aapanel-php-sdk/issues)MITPHPPHP ^7.4|^8.0

Since Jun 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/IAmMasterCraft/aapanel-php-sdk)[ Packagist](https://packagist.org/packages/mastercraft/aapanel-php-sdk)[ RSS](/packages/mastercraft-aapanel-php-sdk/feed)WikiDiscussions main Synced 1mo ago

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

aaPanel PHP SDK
===============

[](#aapanel-php-sdk)

A PHP SDK for interacting with the aaPanel API. This SDK provides convenient methods for managing your aaPanel server, including system status, website management, backup management, domain management, pseudo-static rules, and logs.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Initializing the Client](#initializing-the-client)
    - [System Service](#system-service)
    - [Website Service](#website-service)
    - [Backup Service](#backup-service)
    - [Domain Service](#domain-service)
    - [Ssl Service](#ssl-service)
    - [Pseudo-Static Service](#pseudo-static-service)
    - [Log Service](#log-service)
- ['How To' Guides](#'How-To'-Guides)
    - [How to retrieve list of all existing websites](#How-to-retrieve-list-of-all-existing-websites)
    - [How to add new domain or url to existing websites](#How-to-add-new-domain-or-url-to-existing-websites)
- [Running Tests](#running-tests)
- [Contributing](#contributing)
- [License](#license)

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

[](#installation)

You can install the SDK via Composer. Run the following command:

```
composer require mastercraft/aapanel-php-sdk
```

Usage
-----

[](#usage)

### Initializing the Client

[](#initializing-the-client)

To get started, you need to initialize the AaPanelClient with your aaPanel base URL and API key. It is good practice to set the AAPANEL\_URL and AAPANEL\_API\_KEY values through your environment variables.

**examples/demo.php:**

```
require __DIR__ . '/../vendor/autoload.php';

use Mastercraft\AapanelPhpSdk\AaPanelClient;
use Mastercraft\AapanelPhpSdk\Services\System;
use Dotenv\Dotenv;

$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();

$baseUri = $_ENV['AAPANEL_URL'];
$apiKey = $_ENV['AAPANEL_API_KEY'];

$client = new AaPanelClient($baseUri, $apiKey);

// Example usage
$system = new System($client);
$systemInfo = $system->getSystemTotal();
print_r($systemInfo);
```

### System Service

[](#system-service)

The `System` service allows you to retrieve system status information.

```
use Mastercraft\AapanelPhpSdk\Services\System;

$system = new System($client);

// Get system info
$systemInfo = $system->getSystemTotal();
print_r($systemInfo);

// Get disk information
$diskInfo = $system->getDiskInfo();
print_r($diskInfo);

// Get real-time network status
$networkStatus = $system->getNetwork();
print_r($networkStatus);

// Check for updates
$updateStatus = $system->checkUpdate();
print_r($updateStatus);

// Get Auto Restart Rph
$webname = "www.abc.com";
$rphStatus = $system->getAutoRestartRph($webname);
print_r($rphStatus);

// Auto Restart Rph
$rphStatus = $system->autoRestartRph($webname);
print_r($rphStatus);
```

### Website Service

[](#website-service)

The `Website` service allows you to manage websites on your aaPanel server.

```
use Mastercraft\AapanelPhpSdk\Services\Website;

$website = new Website($client);

// Get list of sites
$sites = $website->getSites();
print_r($sites);

// Create a new site
$newSite = $website->createSite([
    'webname' => '{"domain":"example.com","domainlist":[],"count":0}',
    'path' => '/www/wwwroot/example.com',
    'type_id' => 0,
    'type' => 'PHP',
    'version' => '72',
    'port' => 80,
    'ps' => 'test site',
    'ftp' => true,
    'ftp_username' => 'example_com',
    'ftp_password' => 'password',
    'sql' => true,
    'codeing' => 'utf8',
    'datauser' => 'example_com',
    'datapassword' => 'password'
]);
print_r($newSite);

// Delete a site
$siteId = 66;
$deletedSite = $website->deleteSite($siteId, 'example.com');
print_r($deletedSite);
```

### Backup Service

[](#backup-service)

The `Backup` service allows you to manage website backups.

```
use Mastercraft\AapanelPhpSdk\Services\Backup;

$backup = new Backup($client);

// List backups for a site
$backups = $backup->listBackups($siteId);
print_r($backups);

// Create a new backup
$newBackup = $backup->createBackup($siteId);
print_r($newBackup);

// Delete a backup
$backupId = 121;
$deletedBackup = $backup->deleteBackup($backupId);
print_r($deletedBackup);
```

### Domain Service

[](#domain-service)

The `Domain` service allows you to manage domains for your websites.

```
use Mastercraft\AapanelPhpSdk\Services\Domain;

$domain = new Domain($client);

// List domains for a site
$domains = $domain->listDomains($siteId);
print_r($domains);

// List domains for a site
$domains = $domain->getSiteDomains($siteId);
print_r($domains);

// Add a new domain to a site
$newDomain = $domain->addDomain($siteId, ['webname' => 'example.com', 'domain' => 'new.example.com']);
print_r($newDomain);

// Delete a domain from a site
$deletedDomain = $domain->deleteDomain($siteId, ['webname' => 'example.com', 'domain' => 'new.example.com', 'port' => 80]);
print_r($deletedDomain);
```

### Ssl Service

[](#ssl-service)

The `Ssl` service allows you to manage SSL certificates with Let's Encrypt and other available providers.

```
use Mastercraft\AapanelPhpSdk\Services\Ssl;

$ssl = new Ssl($client);

// Retrieve ssl information
$sslInfo = $ssl->getSslData();
print_r($sslInfo);

// Retrieve ssl certificates
$sslCerts = $ssl->getSslCertificates();
print_r($sslCerts);

// Retrieve Let's Encrypt Account Info
$letsEncrypt = $ssl->getLetsEncryptInfo();
print_r($letsEncrypt);

// Retrieve Registered Panel User (SSL Account) Info
$registeredSslUser = $ssl->getRegisteredUserInfo();
print_r($registeredSslUser);

// Disable current ssl
$sslStatus = $ssl->disableSsl($webname);
print_r($sslStatus);

// Apply for ssl certificate
$certStatus = $ssl->applyForCertificate([
    'domains' => ['example.com', 'example2.com'],
    'id' => $siteId,
]);
print_r($certStatus);

// Enable new ssl certificate
$sslStatus = $ssl->enableSsl([
    'siteName' => $data['webName'],
    'key' => $data['key'],
    'csr' => $data['csr'],
]);
print_r($sslStatus);
```

### Pseudo-Static Service

[](#pseudo-static-service)

The `PseudoStatic` service allows you to manage pseudo-static rules.

```
use Mastercraft\AapanelPhpSdk\Services\PseudoStatic;

$pseudoStatic = new PseudoStatic($client);

// Get pseudo-static rewrite list
$rewriteList = $pseudoStatic->getRewriteList('example.com');
print_r($rewriteList);

// Get rewrite rule content
$rewriteRule = $pseudoStatic->getRewriteRule('/www/server/panel/vhost/rewrite/nginx/example.com.conf');
print_r($rewriteRule);

// Save rewrite rule content
$savedRewriteRule = $pseudoStatic->saveRewriteRule('/www/server/panel/vhost/rewrite/nginx/example.com.conf', 'new content');
print_r($savedRewriteRule);
```

### Log Service

[](#log-service)

The `Log` service allows you to retrieve logs.

```
use Mastercraft\AapanelPhpSdk\Services\Log;

$log = new Log($client);

// Get logs
$logLimit = 10;
$logs = $log->getRealtimeLog($logPath);
print_r($logs);
```

'How To' Guides
---------------

[](#how-to-guides)

This section contains directions and explanations on how to perform certain actions

### How to retrieve list of all existing websites

[](#how-to-retrieve-list-of-all-existing-websites)

Using the `Website` Service, call the `getSites();` method. Additional parameters (`$page` and `$limit`) can be passed for filtering and pagination **Response:**

```
{
    "where",
    "page",
    "data": [
        {
            "id",
            "name",
            "path",
            "status",
            "domain",
            ...
        },
        ...
    ],
    "search_history",
    "net_flow_info"
}
```

### How to add new domain or url to existing websites

[](#how-to-add-new-domain-or-url-to-existing-websites)

Using the `Domain` Service, call the `addDomain($siteId, $domain);` method. **Parameters:**

- `$siteId:` is a unique identifier for the website that this new domain will be pointing to, in order to get the`$siteId`, check the reference on [How to retrieve list of all existing websites](#How-to-retrieve-list-of-all-existing-websites)
- `$domain:` is an array that holds the `webname` of the site we want to point to and `domain` is the new url we are adding. **Response:**

```
{
    "status",
    "msg"
}
```

### How to get ssl for new domain or url

[](#how-to-get-ssl-for-new-domain-or-url)

This process relies heavily on the `Ssl`, `Domain` and `System` Service, you can also refer to the [SSL Example/Demo Script](./examples/ssl-example.php).

- Add the new domain to the website, check the reference on [How to add new domain or url to existing websites](#How-to-add-new-domain-or-url-to-existing-websites) to do that.
- Call the [System Class](#system-service) method to Get Auto Restart Rph action &gt;&gt;&gt; `getAutoRestartRph($webname);`.
- Call the [System Class](#system-service) method to perform Auto Restart Rph action &gt;&gt;&gt; `autoRestartRph($webname);`.
- Call the [Ssl Class](#ssl-service) method to apply for new domain's certificate &gt;&gt;&gt; `applyForCertificate([ 'domains' => ['example.com', 'example2.com'], // list of domain(s) to issue ssl certificate to 'id' => $siteId, ]);`

NOTE: In order to get $siteId, check the reference on \[How to retrieve list of all existing websites\](#How-to-retrieve-list-of-all-existing-websites) - Call the \[Ssl Class\](#ssl-service) method to set/enable the ssl certificate &gt;&gt;&gt; `enableSsl(\[ 'siteName' =&gt; $data\['webname'\], 'key' =&gt; $data\['key'\], 'csr' =&gt; $data\['csr'\], \]);` NOTE: Parameters in the data option to enable Ssl are retrieved from the response received from applying for certificate ```php $certStatus = $ssl-&gt;applyForCertificate(\[ 'domains' =&gt; \['example.com', 'example2.com'\], 'id' =&gt; $siteId, \]);` $data\['key'\] = $certStatus\['private\_key'\]; $data\['csr'\] = $certStatus\['cert'\] . ' ' . $certStatus\['root'\];

```

- Call the [Ssl Class](#ssl-service) method to `getSslData()` and `getSslCertificates()` to check records and confirm ssl certificate setup

## Running Tests

To run the tests, use the following command:

```bash
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests

```

### Example Test Suite

[](#example-test-suite)

**tests/AaPanelClientTest.php:**

```
namespace Mastercraft\AapanelPhpSdk\Tests;

use Mastercraft\AapanelPhpSdk\AaPanelClient;
use Mastercraft\AapanelPhpSdk\Exception\APIException;
use PHPUnit\Framework\TestCase;
use Dotenv\Dotenv;

class AaPanelClientTest extends TestCase
{
    private $apiKey;
    private $baseUri;

    protected function setUp(): void
    {
        $dotenv = Dotenv::createImmutable(__DIR__.'/..');
        $dotenv->safeLoad();
        $this->apiKey = $_ENV['AAPANEL_API_KEY'];
        $this->baseUri = $_ENV['AAPANEL_URL'];
    }

    public function testPost()
    {
        $aaPanelClient = new AaPanelClient($this->baseUri, $this->apiKey);
        $response = $aaPanelClient->post('getSystemTotal');

        $this->assertEquals(['status' => 'success'], $response);
    }

    public function testPostInvalidEndpoint()
    {
        $this->expectException(APIException::class);

        $aaPanelClient = new AaPanelClient($this->baseUri, $this->apiKey);
        $aaPanelClient->post('invalidKey');
    }
}
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

704d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a4284559e534d542f1512200373a320d0b993704fe037a3bf8852fc022fc055?d=identicon)[mastercraft](/maintainers/mastercraft)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mastercraft-aapanel-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/mastercraft-aapanel-php-sdk/health.svg)](https://phpackages.com/packages/mastercraft-aapanel-php-sdk)
```

###  Alternatives

[netflie/whatsapp-cloud-api

The first PHP SDK to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

640431.7k4](/packages/netflie-whatsapp-cloud-api)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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