A PHP client library for interacting with the aaPanel API.
- Fetch logs from the API.
- Add a new site.
- Add a subdomain.
- Delete a subdomain.
- Fetch list of FTP accounts.
- Add a new FTP account.
- Delete an FTP account.
- Import SQL file into a database.
- Save file content to a specified path.
- Unzip a ZIP archive to a specified destination.
- Apply SSL certificate to a domain.
- Renew SSL certificate for a domain.
- Get SSL details for a domain and return the 'index' value.
- Enable HTTPS redirection for a site.
- Disable a site.
- Enable a site.
- Retrieve details of a specific FTP account.
- Set server configuration parameters.
- Get server configuration parameters.
Install the library using Composer:
composer require azozzalfiras/aapanel-api
Initialize the Client
require_once 'vendor/autoload.php';
use aaPanelApiClient;
$apiKey = 'your_api_key'; // get the api key from the settings aapanle
$baseUrl = 'https://example.com:8888'; // Replace with your aaPanel API base URL
$client = new aaPanelApiClient($apiKey, $baseUrl);
$logs = $client->fetchLogs();
var_dump($logs);
$response = $client->addSite('example.com', 'example', 'Example site');
var_dump($response);
$response = $client->addSubdomain('subdomain', 'example.com', '192.168.1.1');
var_dump($response);
$response = $client->deleteSubdomain('subdomain', 'example.com', '192.168.1.1');
var_dump($response);
$ftpAccounts = $client->fetchFtpAccounts();
var_dump($ftpAccounts);
$response = $client->addFtpAccount('ftpuser', 'ftppassword');
var_dump($response);
$response = $client->deleteFtpAccount('ftpuser');
var_dump($response);
$response = $client->importSqlFile('/path/to/example.sql', 'example_database');
var_dump($response);
$fileContent = 'Hello, world!';
$response = $client->saveFile($fileContent, '/path/to/file.txt');
var_dump($response);
$response = $client->unzipFile('/path/to/example.zip', '/path/to/extracted', 'zip_password');
var_dump($response);
$response = $client->applySslCertificate('example.com', 1, 0);
var_dump($response);
$response = $client->renewCert('example.com');
var_dump($response);
$index = $client->getIndexValue('example.com');
var_dump($index);
$response = $client->enableHttpsRedirection('example.com');
var_dump($response);
$response = $client->disableSite(1, 'example.com');
var_dump($response);
$response = $client->enableSite(1, 'example.com');
var_dump($response);
$details = $client->getFtpAccountDetails('ftpuser');
var_dump($details);
$config = [
'param1' => 'value1',
'param2' => 'value2'
];
$response = $client->setServerConfig($config);
var_dump($response);
$config = $client->getServerConfig();
var_dump($config);
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.