As simple as 1, 2, 3…

Simplicity, when it all boils down to getting your job done as fast as possible. We have a really funky rule here, a “lazy developer” is a good developer. Now, a “lazy developer” doesn’t mean one that doesn’t do his job, but one that spends 30 more minutes thinking about what he’s going to do, they writes code that enables him to replicate the result over and over again – at a fraction of the time.

Well, phpari is all about simplicity and getting your job done – simple, clean and fast. Normally, interacting with Asterisk ARI will require you to use either a REST library, or something like cURL. But, phpari takes all that away, wraps it tightly in a rapidly deployed class – making your life as easy as two commands.

Consider the following example: Getting the number of active channels from Asterisk. In the good’ol’days, you would either connect to manager and extract from there, hoping your code doesn’t deadlock. Another option was to issue a shell command, but even that isn’t bullet proof. Now, ARI gives you the ability to query that using an HTTP GET – nice! But even that, without a proper framework can be a little hectic. So, phpari comes to the rescue, making your life really easy:

$conn     = new phpari(ARI_USERNAME, ARI_PASSWORD, "hello-world", ARI_SERVER, ARI_PORT, ARI_ENDPOINT);
echo json_encode($conn->channels()->channel_list());
ARI Get Channels

What happens here? we simply connect to our ARI socket and issue the proper method – that is all. Simple – yes, short – yes, to the point – yes, are you free about your business – yes.


Leave a Reply

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

Please Do the Math