Axigen CLI API Documentation

Axigen CLIAPI

What is CLIAPI?

CLIAPI 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 CLIAPI 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

<?php
    require_once("Axigen.php");
    $session = new Axigen();
    $session->connect("IP", "CLIPORT", "ADMINUSER", "ADMINPASSWORD");
?>

List all accounts from a domain

This sample demonstrates listing all accounts from a domain.

<?php
    require_once("Axigen.php");
    $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";
        exit(1);
    }
    // load accounts
    $accounts = $session->updateDomain("localdomain")->listAccounts();
    var_dump($accounts);
?>

Get server version

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

<?php
    require_once("Axigen.php");
    $session = new Axigen();
    $session->connect("IP", "CLIPORT", "ADMINUSER", "ADMINPASSWORD");
    print $session->axigenVersion();
?>

The sample above will print something like:

10.0.0.1-debug (Linux/x64)|Linux|x86_64

Installing CLIAPI

Software requirements

Axigen CLIAPI 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

  • cliclient.so/dll - needs to be located in php extension directory
  • php files - need to be located in php include path

Installing

  • 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 = "cliclient.so"
  • 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/cliclient.so
  • tar zxvf phpfiles.tgz -C /somepath/AxigenCliApi/
  • restart your apache server
  • to start using AxigenCliApi 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.