Development Guides Home >> Quickstart Development Guide

Tutorial - Create a New cPanel Interface in PHP

Introduction

This tutorial uses PHP to create a new cPanel interface. The examples below use the Jupiter theme's master template, which creates new interfaces that integrate seamlessly with the appearance of the main cPanel interface.

Create a PHP file and connect to the LiveAPI system

To begin, create a new PHP file. This file must use the .live.php file extension.

The example below:

<?php
include("/usr/local/cpanel/php/cpanel.php");  // Instantiate the CPANEL object.
$cpanel = new CPANEL();                       // Connect to cPanel - only do this once.
?>

<?php
$cpanel->end();                               // Disconnect from cPanel - only do this once.
?>

Add Jupiter's header and footer

Use the header() and footer() methods to add Jupiter's header and footer to the interface.

The example below:

<?php
include("/usr/local/cpanel/php/cpanel.php");  // Instantiate the CPANEL object.
$cpanel = new CPANEL();                       // Connect to cPanel - only do this once.
print $cpanel->header( "Page Heading , app_key" );      // Add the header.
?>

<?php
print $cpanel->footer();                      // Add the footer.
$cpanel->end();                               // Disconnect from cPanel - only do this once.
?>

Add a UAPI function

The LiveAPI uapi() method calls UAPI functions.

The example below:

<?php
include("/usr/local/cpanel/php/cpanel.php");  // Instantiate the CPANEL object.
$cpanel = new CPANEL();                       // Connect to cPanel - only do this once.
print $cpanel->header( "Page Heading" );      // Add the header.
?>

<?php
$get_userdata = $cpanel->uapi(                // Get domain user data.
    'DomainInfo', 'domains_data',
    array(
        'format'    => 'hash',
    )
);
?>

 <?php
print $cpanel->footer();                      // Add the footer.
$cpanel->end();                               // Disconnect from cPanel - only do this once.
?>