Development Guides Home >> Quickstart Development Guide
Tutorial - Create a New Paper Lantern Interface in PHP
Introduction
Important:
- This document only applies to customization in the Paper Lantern theme. We deprecated the Paper Lantern theme in cPanel & WHM version 100. For more information, read our cPanel Deprecation Plan documentation.
- To create a new Jupiter interface in PHP, read our Tutorial - Create a New Jupiter Interface in PHP documentation.
This tutorial uses PHP to create a new cPanel interface for the Paper Lantern theme. The examples below use the Paper Lantern theme's master template, which creates new interfaces that integrate seamlessly with the appearance of the main cPanel interface.
- For help to create a new cPanel interface in Template Toolkit, read our Create a New Paper Lantern Interface tutorial.
- For help to create a new WHM interface in PHP, read our Create a New WHM Interface in PHP tutorial.
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:
- Instantiates the CPANEL object, which ensures that the file uses the LiveAPI PHP class .
- Uses the LiveAPI new() method to connect to cPanel & WHM.
- Uses the LiveAPI end() method to disconnect from cPanel & WHM.
<?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 Paper Lantern's header and footer
Use the header()
and footer()
methods to add Paper Lantern's header and footer to the interface.
The example below:
- Uses the LiveAPI header() method to add Paper Lantern's header to the top of the interface, and set Page Heading as the page title.
- Uses the LiveAPI footer() method to add Paper Lantern's footer to the bottom of the interface.
<?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:
-
Uses LiveAPI's
uapi()
method to call UAPI'sDomainInfo::domains_data
function.
<?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.
?>