Over a million developers have joined DZone.

PHP Code, Setup and Demo of Jaxl boshchat application

DZone's Guide to

PHP Code, Setup and Demo of Jaxl boshchat application

· Web Dev Zone ·
Free Resource

Jumpstart your Angular applications with Indigo.Design, a unified platform for visual design, UX prototyping, code generation, and app development.

Jaxl 2.0 bosh support allow web developers to write real time web applications within minutes, without having any pre-requisite knowledge about the XMPP protocol itself. In this blog post, I will walk you through setup and demo of an XMPP based web chat application using Jaxl library.

Get the code
Follow the following steps to download and install this sample web application on your systems:

  • Clone the development branch of Jaxl library

    1. root@ubuntu:~/git# git clone git@github.com:abhinavsingh/JAXL.git  
    2. root@ubuntu:~/git# cd JAXL/  
    3. root@ubuntu:~/git/JAXL# 

  • If you are not familiar with git, simply visit JAXL@github, click Download Source and extract under ~/git/JAXL directory on your system
  • Once inside Jaxl source directory, build the latest development package

    1. root@ubuntu:~/git/JAXL# ./build.sh  
    2. building... 

  • Install Jaxl library (view installation detail and options)

    1. root@ubuntu:~/git/JAXL# ./build.sh install  
    2. uninstalling old package...  
    3. installing... 

Setup web chat application
Jaxl library is default installed under /usr/share/php/jaxl folder. Application code for our web chat application can be found under /usr/share/php/jaxl/app/boshchat folder.

Follow these steps to setup web chat application on your system:

  • I assume you have http://localhost/ configured on your local web server and it runs out of /var/www folder. Create following symlinks:

    1. root@ubuntu:~/git/JAXL# cd /var/www  
    2. root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/boshchat.php index.php  
    3. root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/app/boshchat/jaxl.ini jaxl.ini  
    4. root@ubuntu:/var/www# ln -s /usr/share/php/jaxl/env/jaxl.js jaxl.js  
    5. root@ubuntu:/var/www# ln -s /usr/bin/jaxl jaxl.php 

  • Open and edit jaxl.ini

    1. define('JAXL_BOSH_COOKIE_DOMAIN', false); 

  • I assume you have access to XMPP over Bosh enabled jabber server. Ejabberd users can verify this by hitting http://localhost:5280/http-bind in the browser
  • Open and edit index.php

    1. define('BOSHCHAT_ADMIN_JID''admin@localhost');  

    All messages sent using this web chat application will be routed to BOSHCHAT_ADMIN_JID

Ready for the demo
To run this example web chat application, visit http://localhost in your browser window. Enter a username/password already registered on your jabber server and press connect.

Login as BOSHCHAT_ADMIN_JID using a desktop client, so that you can receive messages sent from the browser on your desktop client.

Below is a screenshot when I logged in as “abhinavsingh” from browser and BOSHCHAT_ADMIN_JID was set to “jaxl@jaxl.im”:

Take a look at an Indigo.Design sample application to learn more about how apps are created with design to code software.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}