LivePHP Documentation
LivePHP is a PHP environment you can utilize within cPanel. This PHP environment provides PHP scripts with a local socket to the cPanel binary,
cpsrvd. This allows your script to make API1 and API2 calls to the local machine via the socket.
/usr/local/cpanel/php/cpanel.php is an out-of-the-box PHP class that provides common elements for this integration . API calls are executed by the system's user and may fail if asked to perform a task for which the user has insufficient permissions. The same rules apply to this method as when using API tags or API calls made via our XML API
To begin, you must ensure that you meet the following 3 criteria:
- You must include /usr/local/cpanel/php/cpanel.php and instantiate the
CPANEL object.
- Your PHP scripts' file names must end in either
.livephp or .live.php
- You must place your PHP script in /usr/local/cpanel/base/frontend/$THEME You may also use a symlink.
-
Note: You will need to replace $THEME in the example above with your theme. (e.g. x3 in most cases)
The CPANEL PHP Class
Class Description
This class provides an interface to the local system's cPanel binary. It allows you to make API calls and use cPanel tags as described in
Developer Resources. Your can make both API1 and API2 calls using this class.
- Version: 0.1 — You can find this class at /usr/local/cpanel/php/cpanel.php
- Copyright: cPanel, Inc.
- License: Modified BSD
-
Note: This class depends on /usr/local/cpanel/php/xml.php.
Class Variable Summary
Public Variables
Private Methods
- Private methods are not itemized here. See
cpanel.php
Note: You may pass
$TODO private variables here.
Class Method Summary
Public Methods
- void CPANEL ()
- array api ( string $reqtype, string $version, string $module, string $func, array $args)
- array api1 (string $module, string $func, array $args)
- array api2 (string $module, string $func, array $args)
- boolean cpanelfeature (string $expression)
- boolean cpanelif (string $expression)
- boolean cpanellangprint (string $textkey)
- boolean cpanelprint (string $expression)
- void end ()
- array exec (string $code)
- array fetch (string $code)
Private Methods
- Private variables are not itemized here. See
cpanel.php.
Class Method Details
CPANEL =(line 36)
| Description |
Get user scope socket handle to cPanel binary. (e.g. Constructor) |
| Return |
Nothing. |
| Access |
Public |
| Example |
CPANEL () |
api =(line 99)
| Description |
Queries the cpsrvd binary for information. |
| Return |
A PHP array representation of an XML response. |
| Access |
Public |
| Output Type |
Array |
| Example |
api ($reqtype, $version, $module, $func, $args) |
Parameters:
-
$reqtype (string) — The type of request. This value is usually exec.
-
$version (integer) — The API version. This value is either 1 or 2.
-
$module (string) — The name of the module you wish to use.
-
$func (string) — The name of the function you wish to use.
-
$args (array) — Any arguments you wish to pass to the API function. API 1 arguments are in ordered array keys. API 2 arguments are passed as literal array keys.
api1 =(line 75)
| Description |
Executes an API1 query. |
| Return |
A PHP array representation of an XML response |
| Access |
Public |
| Output Type |
Array |
| Example |
api1 ($module, $func, $args) |
Parameters:
-
$module (string) — The module's namespace. (e.g. SSL)
-
$func (string) — The function you wish to call. (e.g. gencrt)
-
$args (array) — The arguments you wish to pass to the function. Keys must be ordered when using an API 1 function. (e.g. array(0=>'funcArg1', 1=>'funcArg2'))
api2 =(line 79)
| Description |
Executes an API2 query. |
| Return |
A PHP array representation of an XML response. |
| Access |
Public |
| Output Type |
Array |
| Example |
api2 ($module, $func, $args) |
Parameters:
-
$module (string) — The module's namespace. (e.g. SSL)
-
$func (string) — The function you wish to call. (e.g. gencrt)
-
$args (array) — The arguments you wish to pass to the function.
-
Note: Array keys must be literal.
cpanelfeature =(line 87)
| Description |
Functions as a wrapper for cPanel feature tags. |
| Return |
A PHP array representation of an XML response. |
| Access |
Public |
| Output Type |
Boolean |
| Example |
cpanelfeature ($expression) |
Parameters:
-
$expression (string) — A logic expression. For more information visit our documentation here.
cpanelif =(line 83)
| Description |
This functions as a wrapper for the cpanelif tag. |
| Return |
The value of the XML response's result node. |
| Access |
Public |
| Output Type |
Boolean |
| Example |
cpanelif ($expression) |
Parameters:
-
$expression (string) — A logic expression. For more information visit our documentation here.
cpanellangprint =(line 95)
| Description |
This functions as a wrapper for the cPanel langprint function. |
| Return |
The value of an XML response's result node. |
| Access |
Public |
| Output Type |
Boolean |
| Example |
cpanellangprint ($textkey) |
Parameters:
-
$textkey (string) — A reference to a locale (language).
cpanelprint =(line 91)
| Description |
This functions as a wrapper for the cPanel print function. |
| Return |
The value of an XML response's result node. |
| Access |
Public |
| Output Type |
Boolean |
| Example |
cpanelprint ($expression) |
Parameters:
-
$expression (string) — A logic expression. For more information visit our documentation here.
end =(line 121)
| Description |
Deconstructs the class object. |
| Access |
Public |
| Output Type |
Void |
| Example |
end () |
exec =(line 59)
| Description |
Executes a cPanel tag. Calling exec directly is discouraged. |
| Return |
A PHP array representation of an XML response. |
| Access |
Public |
| Output Type |
Array |
| Example |
exec ($code) |
Parameters:
-
$code (string) — A cPanel tag that contains an API, ExpVar, or a Dynamic UI construct.
fetch =(line 52)
| Description |
This functions as a wrapper for the cPanel API print function. This returns the entire XML response as a PHP array. If you only want the data result, use cpanelprint. |
| Return |
A PHP array representation of an XML response. |
| Access |
Public |
| Output Type |
Array |
| Example |
fetch ($code) |
Parameters:
-
$code (string) — A cPanel tag that contains an API, ExpVar, or a Dynamic UI construct.
Topic revision: r12 - 17 Aug 2011 - 15:26:15 - Main.JustinSchaefer
AllDocumentation/AutomationIntegration.LivePHP moved from Sandbox.LivePHP on 14 Apr 2010 - 20:36 by Main.JustinSchaefer