mofh-vp-api-wrapper is a powerful PHP client library designed for VistaPanel, the control panel used by MyOwnFreeHost (MOFH) resellers. It enables developers to programmatically manage websites, databases, domains, redirects, SSL certificates, and more β all through a clean and simple API interface.
This library is a successor to VPClient/GenerateClient and a modern fork of oddmario/vistapanel-php-api.
VistaPanel is the control panel used by MOFH-powered hosting accounts. The VistaPanel API allows automation of hosting management actions such as:
- Logging in and managing sessions
- Creating and deleting MySQL databases
- Managing domains, subdomains, and redirects
- Uploading SSL certificates and keys
- Integrating with Softaculous
- Handling notifications and user sessions programmatically
With mofh-vp-api-wrapper, you can easily connect to your VistaPanel instance and automate all of the above using simple PHP methods.
You can include the library manually or install it via Composer (if supported).
- Download the library files.
- Include it in your PHP script:
require_once 'mofh-vp-api-wrapper.php';This is the main class that manages all VistaPanel API operations.
| Property | Type | Description |
|---|---|---|
cpanel_url |
string | The base URL of your VistaPanel control panel. |
logged_in |
bool | Indicates whether the session is currently logged in. |
vistapanel_session |
string | The session ID obtained after logging in. |
vistapanel_session_name |
string | The name of the VistaPanel session cookie. |
vistapanel_token |
string | The token required for API authentication. |
account_username |
string | The username of the currently logged-in account. |
cookie |
string | The full cookie string used for authenticated requests. |
Sets the URL of the VistaPanel control panel.
Parameters:
$url(string) β The full control panel URL (e.g.,https://cpanel.example.com)
Example:
$api->set_cpanel_url('https://cpanel.example.com');Logs into the VistaPanel control panel.
Parameters:
$username(string) β VistaPanel username$password(string) β VistaPanel password$theme(string) β The panel theme (default:'PaperLantern')
Example:
$api->login('user123', 'securepassword', 'PaperLantern');Creates a new MySQL database.
Parameters:
$dbname(string) β The database name (without account prefix)
Example:
$api->create_database('new_db');Returns an array of all MySQL databases associated with the logged-in account.
Example:
$databases = $api->list_databases();
print_r($databases);Deletes a specific MySQL database.
Parameters:
$database(string) β Database name (without prefix)
Example:
$api->delete_database('old_db');Retrieves the phpMyAdmin login link for a specific database.
Parameters:
$database(string) β Database name (without prefix)
Example:
$link = $api->get_phpmyadmin_link('example_db');
echo $link;Lists all domains associated with the account.
Parameters:
$option(string) β The domain type:'all','addon','sub', or'parked'(default:'all')
Example:
$domains = $api->list_domains('addon');
print_r($domains);Creates a redirect from one domain to another.
Parameters:
$domainname(string) β Source domain name$target(string) β Destination URL
Example:
$api->create_redirect('example.com', 'https://newsite.com');Removes an existing redirect.
Parameters:
$domainname(string) β Domain name whose redirect should be deleted
Example:
$api->delete_redirect('example.com');Uploads a private key and CSR for SSL installation.
Parameters:
$domainname(string) β Target domain$key(string) β SSL key content$csr(string) β Certificate Signing Request content
Example:
$api->upload_key('example.com', $ssl_key, $csr_data);Uploads an SSL certificate for a domain.
Parameters:
$domainname(string) β Target domain$cert(string) β SSL certificate content
Example:
$api->upload_cert('example.com', $certificate);Retrieves the currently installed SSL private key.
Parameters:
$domain(string) β Domain name
Example:
$key = $api->get_ssl_private_key('example.com');Retrieves the installed SSL certificate.
Parameters:
$domain(string) β Domain name
Example:
$cert = $api->get_ssl_certificate('example.com');Returns the Softaculous (auto-installer) URL.
Example:
$link = $api->get_softaculous_link();
echo $link;Logs out of VistaPanel and resets all client configuration.
Example:
$api->logout();Allows iFastNet to send suspension and alert notifications to the control panel. Also unlocks the control panel if locked.
Example:
$api->approve_notification();<?php
require_once 'mofh-vp-api-wrapper.php';
$api = new Vistapanel_Api();
$api->set_cpanel_url('https://cpanel.example.com');
$api->login('username', 'password');
// List all databases
$databases = $api->list_databases();
foreach ($databases as $db) {
echo $db . PHP_EOL;
}
// Create a new redirect
$api->create_redirect('example.com', 'https://redirectedsite.com');
// Log out when done
$api->logout();
?>- mofh-javascript β Customize VistaPanel with JavaScript
- oddmario/vistapanel-php-api β Original PHP API library
This project is licensed under the MIT License. See the LICENSE file for details.