The preferred method of installation is via composer. You may find additional information about the actual composer.json file for this at

The recommended file is as follows:

    "require": {
        "php": ">=5.3.9",
        "educoder/pest": "1.0.0",
        "devristo/phpws": "dev-master",
        "greenfieldtech-nirs/phpari": "dev-master"
composer.json file to use phpari

We recommend working with the dev-master package, as the code is being maintained on a daily basis.

The basic Stasis application wireframe

 * Created by PhpStorm.
 * User: WildCard
 * Date: 9/6/14
 * Time: 12:38 AM

require_once "../vendor/autoload.php";

class BasicAriConnector
    public function __construct()
        //   $phpariObject = new phpari("ariuser", "4r1u53r", "hello-world", "", 8088, "/ari");
        $phpariObject = new phpari("lnotik", "hwab7bk", "hello-world", "", 8088, "/ari");

        $this->ariEndpoint   = $phpariObject->ariEndpoint;
        $this->stasisClient  = $phpariObject->stasisClient;
        $this->stasisLoop    = $phpariObject->stasisLoop;
        $this->stasisLogger  = $phpariObject->stasisLogger;


    public function handlers()
        try {
            $this->stasisClient->on("request", function ($headers) {
                $this->stasisLogger->notice("Request received!");

            $this->stasisClient->on("handshake", function () {
                $this->stasisLogger->notice("Handshake received!");

            $this->stasisClient->on("message", function ($message) {



        } catch (Exception $e) {
            echo $e->getMessage();

    public function execute()
        try {

        } catch (Exception $e) {
            echo $e->getMessage();


$basicAriClient = new BasicAriConnector();

 * Get some basic information from ARI
$ariAsterisk = new asterisk($basicAriClient->ariEndpoint);
$ariAsteriskInformation = $ariAsterisk->get_asterisk_info();
$ariChannels = new channels($basicAriClient);
$ariAsteriskChannels = $ariChannels->channel_list();





     * phpari - A PHP Class Library for interfacing with Asterisk(R) ARI
     * Copyright (C) 2014  Nir Simionovich
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Lesser General Public
     * License as published by the Free Software Foundation; either
     * version 2.1 of the License, or (at your option) any later version.
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * Lesser General Public License for more details.
     * You should have received a copy of the GNU Lesser General Public
     * License along with this library; if not, write to the Free Software
     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     * Also add information on how to contact you by electronic and paper mail.
     * Greenfield Technologies Ltd., hereby disclaims all copyright interest in
     * the library `phpari' (a library for creating smart telephony applications)
     * written by Nir Simionovich and its respective list of contributors.

    /* Should be identical to the context, defined in /etc/asterisk/ari.conf */
    define("ARI_USERNAME",  "ari_username");

    /* Should be identical to the password, defined in /etc/asterisk/ari.conf */
    define("ARI_PASSWORD",  "ari_password");

    /* Your Asterisk IP number */
    define("ARI_SERVER",    "");

    /* Your Asterisk ARI port number */
    define("ARI_PORT",      8088);

    /* Your Asterisk ARI HTTP endpoint */
    define("ARI_ENDPOINT",  "/ari");

To activate the Stasis application, simply issue the following command from the console:

php BasicAriConnector.php

The script will connect to the ARI 8088 port and will enable the “hello-world” stasis application – available from the Asterisk dialplan.

13 comments for “Documentation

  1. November 7, 2014 at 10:46 am

    i am afraid that this doesnt work?

    $phpariObject = new phpari(“lnotik”, “hwab7bk”, “hello-world”, “”, 8088, “/ari”);

    in new version in version e349ba3bea1cc77e5ed6076cad3bae760b8ba72a ?

    bcs the phpari object changed

    public function __construct($stasisApplication = NULL, $configFile = “phpari.ini”)

    • admin
      November 19, 2014 at 9:26 am

      This had been deprecated in favor of a configuration file, please refer to the documentation for additional information.

  2. Modestas
    November 27, 2014 at 9:33 am

    I have a question how i can get require_once(../vendor/autoload.php) The autoload.php file. How i create it or download it from where?

    • admin
      December 28, 2014 at 6:30 am


      The autoload is part of the composer methodology of work. I suggest that you head on to and read the “Getting Started” section – it’s really simple. Once you learn it, it will make your entire life with PHP so much easier, that you won’t even understand how you worked without it before.


  3. Sergey
    May 27, 2015 at 11:49 am

    what kind of load can withstand phpari?

    • admin
      May 29, 2015 at 3:29 pm

      Well, I hadn’t yet fully load tested it – but you are welcome to do so. I’ve already managed to run around 100 concurrent calls with a single PHPARI
      stasis application, but again, each application is a little different and mileage may vary.

  4. Shankar
    August 20, 2015 at 1:22 pm

    i’m successfully installed through composer, but ari not connecting to server, and getting this error “ raised: Missing PestObject or empty string File: /home/chand3bk/public_html/chandu/astirisk/src/interfaces/asterisk.php Line: 36”.

    am i missing anything here, please suggest me.

    phpari.ini file as follows:
    logfile=console ; console for direct console output, filename for file based logging

    transport=ws ; ws for none encrypted, wss for encrypted (currently, only ws is supported)


    • admin
      August 20, 2015 at 1:33 pm

      You need to change the “host” section in “asterisk_ari” – you are still using my testing server IP number 🙂
      I would probably say that your Asterisk ARI configuration is also not complete. If you are around Astricon,
      you are welcome to join my “From PHPAGI to PHPARI” talk, to learn more about PHPARI.

  5. Shankar
    August 20, 2015 at 2:15 pm

    Thank you so much for your quick reply. Currently we are testing Asterisk ARI (PHP) in our hosting server.

    How can we test that our ARI connection working or not and configured correctly? We didn’t find clear documentation for ARI at anywhere. We only found examples. Can you please suggest the documentation where we can find for ARI.

    We are developers and our client interested to take Asterisk ARI (PHP), and requested us to install and test the ARI connection. We are trying our best to findout documentation but didn’t get anywhere.

    Can you please guide us how to configure the Asterisk ARI (PHP).

    • admin
      August 20, 2015 at 3:44 pm

      Hi Shankar,

      Checkout “An introduction to PHPARI” page in the documentation section, should get you up and running faster.

  6. Shankar
    August 20, 2015 at 4:29 pm

    Thank you for your guidance. Can you please let me know that “Do we need Device to confirm that Astrisk ARI PHP configuration is Working and Channels list?

    We configured with localhost [host” section in “asterisk_ari” ] and still getting the same error “Missing PestObject or empty string” at asterisk.php Line: 36. Can you please guide us how to test in localhost.

  7. Shankar
    August 20, 2015 at 4:34 pm

    Also guide us what is the value/path of the [EndPoint] endpoint=/ section in “asterisk_ari”.

    • admin
      August 22, 2015 at 3:45 pm

      I’ve updated the document with additional information, I believe it should be clear now.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Do the Math