CLI API Documentation

Axigen's PHP Command Line Interface API reference guide

What is CLI API?

CLI API is a PHP wrapper that allows an administrator to programatically perform administration tasks on an Axigen server, such as provisioning accounts, domains or mailing lists or configuring various server parameters. It is built on top of the Axigen Command Line Interface service and it exposes many (but not all) of the commands that are available in the CLI.

When using CLI API work begins in the Axigen class (also called "the CLI Object"). The Axigen class contains code that allows the caller to establish a session to the Axigen server (using the Axigen::connect function). Once a session is established other methods can be called that return their own clasess that can be used to perform provisioning actions.

Code Examples

Establish a session

    $session = new Axigen();
    $session->connect("IP", "CLIPORT", "ADMINUSER", "ADMINPASSWORD");

List all accounts from a domain

This sample demonstrates listing all accounts from a domain.

    $session = new Axigen();
    $session->connect("IP", "CLIPORT", "ADMINUSER", "ADMINPASSWORD");

    // check if the domain exists
    $domains = $session->listDomains();
    if(!in_array("localdomain", $domains)) {
        print "The domain \"localdomain\" doesn't exist";
    // load accounts
    $accounts = $session->updateDomain("localdomain")->listAccounts();

Add a new account (mailbox) in a domain

This sample demonstrates creating a new account in a domain, updating the new account's contact data and adding an account alias.

    # get the domain object
    $domain = $session->updateDomain("bisisica");

    # create a new account
    $account = $domain->addAccount("user10", "usr10pwd");

    # update the newly created's account data
    $account = $domain->updateAccount("user10");
    $contact_info = $account->configContactInfo();
    $contact_info->firstName = "John";
    $contact_info->lastName = "Doe";
    # add an alias
    # save changes

Get server version

This sample demonstrates connecting to the Axigen CLI and retrieving the server version.

    $session = new Axigen();
    $session->connect("IP", "CLIPORT", "ADMINUSER", "ADMINPASSWORD");
    print $session->axigenVersion();

The sample above will print something like: (Linux/x64)|Linux|x86_64

Configure catchAll for a domain

This sample demonstrates configuring catchAll for a domain.

    $session = new Axigen();
    $session->connect("IP", "CLIPORT", "ADMINUSER", "ADMINPASSWORD");

    $domain = $session->updateDomain("");
    $domain->catchAllType = "account";
    $domain->catchAllAccountName = "postmaster";
    $domain->catchAllFolderName = "ca_folder";

Installing CLI API

Software requirements

Axigen CLI API runs on:

  • Linux supported platforms (e.g. RedHat, CentOS, Debian, Ubuntu).
  • Windows supported platforms (Windows 2008, 2012)
  • PHP supported versions (5.2-5.6)

Files and directories

  • - needs to be located in php extension directory
  • php files - need to be located in php include path


  • edit your php.ini
  • search for extension_dir and see where the path is set to
  • search for include_path
  • append to include path ":/somepath/AxigenCliApi/"
  • append the following line to your php.ini: extension = ""
  • check php if is compile with threads or not to see what cliclient to copy
  • check your OS, CPU to see what cliclient library to copy
  • mv cliclient_(OS)_(CPU)_(THREADS).so to the path from extension_dir/
  • tar zxvf phpfiles.tgz -C /somepath/AxigenCliApi/
  • restart your apache server
  • to start using Axigen CLI API, include "Axigen.php" and check the CLI Object Documentation on how to use it.

Check for PHP Threads support

You can check if your php has Threads support by following these steps:

  • php cli:
  • run this command in a shell:
    • php --info | grep "Threads Safety"
  • php apache:
  • create a php file containing <?php phpinfo(); ?>
    • fetch that file via apache and find the "Threads Safety" string
  • If "Threads Safety" is enabled, use the library with threads, otherwise, use the one with no threads.