Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

PHP In The cPanel Interface

For cPanel & WHM 11.30 and older

ALERT! Warning: As of cPanel & WHM 11.30, we have refactored this system so that it applies to an expanding list of scripting languages. You should review the LiveAPI documentation for the most recent information.

Overview

cPanel allows for additional pages to be written in PHP rather than HTML. This provides full access to our APIs via our API tags.

Usage

To use cPanel PHP, place a PHP script anywhere inside of the following directory: /usr/local/cpanel/base/frontend/

This directory corresponds to the following URL:

  • http://www.example.com:2082/frontend/

ALERT! Warning: If you place a PHP script outside of this directory, the source code will be exposed.

cPanel tags are still available by using <cpanel> and <?cp> tags. These tags can be executed before or after the PHP script. The order of execution is determined by the file extension used:

  • .php — Executes cPanel tags before the PHP code.
  • .cpphp — Executes cPanel tags before the PHP code.
  • .phpcp — Executes the PHP code followed by the cPanel tags.

PICK Important: cPanel PHP files should never use the short opening tag for PHP. Instead, you should use <?php

cPanel PHP functions

The following cPanel-specific PHP functions are available:

Function Description
loadvars() This function loads information about your server and the cPanel account's settings.
loadparkeddomains() This function loads information about the account's parked domains.
loadsubdomains() This function loads information about the account's subdomains.
loaddocroots() This function loads information about the account's document root.

The cPanel PHP functions use the following syntax:

<cpanel PHP="loadvars()">

Much of the same information provided by the cPanel PHP functions can be obtained through the DomainLookup API2 Module.

Example

A demonstration PHP page is available in the following location: /usr/local/cpanel/base/frontend/x3/test.php

This page corresponds to the following URL:

  • http://www.example.com:2082/frontend/x3/test.php

The page demonstrates POST, GET and FILE input types at the top of the page, and the four cPanel previously-listed PHP functions.

System Information

This system is provided by a custom PHP binary that is located in one of the following directories:

  • /usr/local/cpanel/3rdparty/bin/php
  • /var/cpanel/3rdparty/bin/php

php.ini for cPanel PHP is available at: /usr/local/cpanel/3rdparty/etc or /var/cpanel/3rdparty/etc

ALERT! Warning: cPanel recommends that you do not change this PHP binary, and we will not support any changes made to it.

Topic revision: r9 - 28 Mar 2013 - 16:15:00 - Main.LaurenceSimon
AllDocumentation/AutomationIntegration.CpanelPhp moved from Sandbox.UsingPHPInterface on 30 Sep 2009 - 19:36 by Main.JustinSchaefer