Download the PHP package mastercraft/aapanel-php-sdk without Composer
On this page you can find all versions of the php package mastercraft/aapanel-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package 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
- Installation
- Usage
- Initializing the Client
- System Service
- Website Service
- Backup Service
- Domain Service
- Ssl Service
- Pseudo-Static Service
- Log Service
- 'How To' Guides
- How to retrieve list of all existing websites
- How to add new domain or url to existing websites
- Running Tests
- Contributing
- License
Installation
You can install the SDK via Composer. Run the following command:
Usage
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:
System Service
The System
service allows you to retrieve system status information.
Website Service
The Website
service allows you to manage websites on your aaPanel server.
Backup Service
The Backup
service allows you to manage website backups.
Domain Service
The Domain
service allows you to manage domains for your websites.
Ssl Service
The Ssl
service allows you to manage SSL certificates with Let's Encrypt and other available providers.
Pseudo-Static Service
The PseudoStatic
service allows you to manage pseudo-static rules.
Log Service
The Log
service allows you to retrieve logs.
'How To' Guides
This section contains directions and explanations on how to perform certain actions
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:
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$domain:
is an array that holds thewebname
of the site we want to point to anddomain
is the new url we are adding. Response:
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.
- Add the new domain to the website, check the reference on How to add new domain or url to existing websites to do that.
- Call the System Class method to Get Auto Restart Rph action >>>
getAutoRestartRph($webname);
. - Call the System Class method to perform Auto Restart Rph action >>>
autoRestartRph($webname);
. - Call the Ssl Class method to apply for new domain's certificate >>>
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 - Call the Ssl Class method to set/enable the ssl certificate >>>
enableSsl([ 'siteName' => $data['webname'], 'key' => $data['key'], 'csr' => $data['csr'], ]);
NOTE: Parameters in the data option to enable Ssl are retrieved from the response received from applying for certificate
- Call the Ssl Class method to
getSslData()
andgetSslCertificates()
to check records and confirm ssl certificate setup
Running Tests
To run the tests, use the following command:
Example Test Suite
tests/AaPanelClientTest.php:
Contributing
Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.
License
This project is licensed under the MIT License. See the LICENSE file for details.