Jaxl 2.0 – Installation, Usage guide and Example apps

Jaxl 2.0 – Installation, Usage guide and Example apps

This blog post provides detailed instructions on how to download and setup Jaxl 2.0 for quick XMPP application development using PHP. We will also see how to run XMPP bots using Jaxl command line utility (now available by just typing jaxl on the terminal).

Get the source code
Jaxl 2.0 development version source code is available at github.

  • For better experience download latest stable tarball from google code
  • The development version of Jaxl is hosted here at Github, have fun cloning the source code with Git. If you are not familar with Git just use the download button to get a tarball.
    [email protected]:~/git# git clone git://github.com/abhinavsingh/JAXL.git

Warning: the development source code is only intended for people that want to develop Jaxl or absolutely need the latest features still not available on the stable releases.

Installation on *nix Systems
Extract the downloaded tarball and enter source directory. The available build.sh file will help us installing Jaxl library at a preferred location on our system. Type ./build.sh help to view help instructions:

[email protected]:~/git# cd JAXL
[email protected]:~/git/JAXL# ./build.sh help

Build file will default install Jaxl library core under /usr/share/php/jaxl and Jaxl command line at /usr/bin/jaxl. Open build script, edit PACKAGE_INSTALL_PATH and PACKAGE_BIN_PATH to configure installation paths.

Issue following commands to setup Jaxl library core and Jaxl command line utility:

[email protected]:~/git/JAXL# mkdir /usr/share/php/jaxl
[email protected]:~/git/JAXL# ./build.sh
[email protected]:~/git/JAXL# ./build.sh install
uninstalling old package...
[email protected]:~/git/JAXL# touch /var/log/jaxl.log
[email protected]:~/git/JAXL# chown www-data /var/log/jaxl.log
[email protected]:~/git/JAXL# touch /var/run/jaxl.pid
[email protected]:~/git/JAXL# chown www-data /var/run/jaxl.pid

/var/log/jaxl.log is default log file for Jaxl applications and /var/run/jaxl.pid saves the process id (pid) of running Jaxl instances.

Usage guide
Now that we have setup Jaxl on our system, lets verify package installation by firing jaxl command line utility on the terminal:

[email protected]:~/git/JAXL# jaxl
Missing ini file...

If you get “Missing ini file” message, you have successfully verified package installation. This message is shown when current working directory doesn’t have jaxl.ini file, which is required by Jaxl cli utility before it can connects to a jabber server.

Running sample applications
Build script installs a sample application under /usr/share/php/jaxl/app/echobot directory. This directory contains two files namely:

  • echobot.php: Contains our echobot application code
  • jaxl.ini: It is application specific Jaxl configuration file

Open and update the following section inside jaxl.ini:

        // Connecting bot details
        define('JAXL_USER_NAME', 'username');
        define('JAXL_USER_PASS', 'password');

        // Connecting jabber server details
        define('JAXL_HOST_NAME', 'jabber.org');
        define('JAXL_HOST_PORT', 5222);
        define('JAXL_HOST_DOMAIN', 'jabber.org');

Now run the echobot from using jaxl cli utility:

[email protected]:/usr/share/php/jaxl/app/echobot# jaxl echobot.php
== 2946 == [[2010-08-02 14:37:53]] Socket opened to the jabber host jabber.org:5222 ...
== 2946 == [[2010-08-02 14:37:57]] Performing Auth type: DIGEST-MD5
== 2946 == [[2010-08-02 14:38:02]] Auth completed...

2946 is the process id of current running Jaxl instance. Same value can be found inside /var/run/jaxl.pid. Also tail the Jaxl log file for debug information:

[email protected]:~/git/JAXL# tail -f /var/log/jaxl.log
== 2946 == [[2010-08-02 14:38:02]] [[XMPPSend]] 123
chatOnline using Jaxl (Jabber XMPP Library in PHP)1

[[XMPPSend]] tells us that following XMPP packet was send by the Jaxl instance running with pid 2946. Also, total 123 bytes were transmitted over the socket.

Proceed to Writing your first command line bot using Jaxl for detailed explanation of the sample echobot application or if you are interested in building real-time web applications read Setup and Demo of Jaxl boshchat application


  1. Pingback: Releasing Jaxl 2.0 – Object oriented XMPP framework in PHP | Abhi's Weblog

  2. Pingback: Writing a command line XMPP bot (echobot) using Jaxl 2.0 | Abhi's Weblog

  3. Pingback: Jaxl 2.0 Core classes, available methods and directory structure | Abhi's Weblog

  4. Pingback: Facebook chat connect with X-FACEBOOK-PLATFORM using Jaxl 2.0 | Abhi's Weblog

  5. Pingback: PHP Code, Setup and Demo of Jaxl boshchat application | Abhi's Weblog

  6. Pingback: XEP 0045 – Multi User Chat (MUC) available methods in Jaxl 2.0 | Abhi's Weblog

  7. Pingback: How to write External Jabber Components in PHP using Jaxl library? | Abhi's Weblog

  8. aka

    i dont understand this jaxl platform, I mean there is not finish application that i can use and test to see how it’s work and learn from it?
    i mean some application that works?

  9. Hi Aka,

    Kindly join the group http://groups.google.com/group/jaxl where other developers can help you out with specific problems…

    I am not sure how you are trying to implement Jaxl on your system? What is your system configuration? What are the exact steps that you followed? What do you see inside jaxl.log, which can probably help us debug your problem in detail.

    Every single example application works out on linux/windows, you probably are missing out the basic clue somewhere… 🙂

  10. prem

    Dear abi,
    I have installed ejabber in my system.

    When i run the echobot to make my id online always .

    I have configured the jaxl.ini file in echobot.Still my id not becomes online in my jabber server.When i login the same id in jabber client like gajim or kopete.Then the id becomes login in my ejabber server.

    Below are the messages displayed when i run the ejabber server.

    jaxl echobot.php
    [7479] 2010-12-31 14:47:46 – Registering shutdown for SIGH Terms …
    [7479] 2010-12-31 14:47:46 – Openssl enabled …
    [7479] 2010-12-31 14:47:46 – Socket opened to the jabber host matrimony.net:5222 …

    Thank you,

    With Regards,

  11. Richard Robertson

    Sigh. Yet another client. I’m trying to set up a XMPP chat HOST. I’m using a web hosting site. I do not have shell access. I cannot run the chat system as a background process. I had my site hosting company open the necessary ports already. I can do the latest PHP and Perl programs, scripted or pre-compiled. I’m working with a private group with sensitive data and I can’t go through a third party host. Obviously submitting any such website for “pre-approval” is out of the question. Is there any use I can get out of your library for such a project?

    1. Hi Vikas,

      You can use Net_DNS package from PEAR repository. Since it is not supported on windows, i didn’t made it as a dependency inside Jaxl core.
      However it should be easy to use & integrate that if you want to.

  12. Vlad

    I have a big problem, very very frustrating.

    I keep getting this error when I try to run the example from above:
    Fatal error: Call to undefined function jaxl_require() in /usr/local/lib/php/jaxl/core/jaxl.class.php on line 41

    I installed the Jaxl on my linux dedicated several times… but I stilll get this error.

    Can anyone help?


  13. Vlad

    IT seems that the latest version fixed that problem, but now, I am receiving this:
    [[XMPP]] Unable to open socket to the jabber host

    I am sure this is not a Jaxl problem, but any idea what I can do to fix it?


  14. JooJar


    Whilst I thank you for the library you’ve developed the documentation, and instructions are a little poor.

    There is no build.sh in the latest release, so people following this tutorial like myself are left hanging until you respond to us. Please update your blog as to why there is no build.sh and what we should do to install it.

  15. Matt

    Do i need to install the new version anyhow?

    I downloaded your package, extracted it to some location on my server, edited echobot.php with correct gtalk info and ran echobot.php in my browser.

    I only get a blank page there.
    Am I doing something wrong?

  16. Hafiz

    Hope this is not spam here :

    Hi Abhinav, already test your v2.1.2… Is this just can run on localhost? Can’t run on web hosting? I’m using PHP5 too and test your code more than 5 hours just now and nothing I got for possible run FB Chat… 🙁

    I think your guide not complete or not update. Hope you can make a new post and telling how to & step by step about new version…

    I already test your old version too, and seriously I got nothing here… And I don’t know this is the truth code can use FB Chat or not… Still try and try but now very stuck just focus on your code…

  17. Alex

    hi, i get the error in error log when the application is installed to my fb profile

    Stack trace:
    #0 /home/domain/public_html/jaxl/app/echobot.php(19): JAXL->__construct(Array)
    #1 {main}
    thrown in /home/domain/public_html/jaxl/core/jaxl.class.php on line 695
    [25-Mar-2011 09:51:17] PHP Warning: touch(): Unable to create file /var/run/jaxl.pid because Permission denied in /home/domain/public_html/jaxl/core/jaxl.class.php on line 695
    [25-Mar-2011 09:51:17] PHP Fatal error: Uncaught exception ‘JAXLException’ with message ‘Pid file /var/run/jaxl.pid doesn’t exists’ in /home/domain/public_html/jaxl/core/jaxl.class.php:695
    Stack trace:

    how to fix this? :

  18. Nil


    I am using JAXL 2.1.1. I have installed it following the procedure described in the blog above. I then tried the echobot.php for getting online presence information from facebook. However, the program is getting halted after the following steps:

    [[email protected] echobot]# jaxl echobot.php
    [5477] 2011-04-02 06:17:24 – Registering shutdown for SIGH Terms …
    [5477] 2011-04-02 06:17:24 – Openssl enabled …
    [5477] 2011-04-02 06:17:24 – Socket opened to the jabber host chat.facebook.com:5222 …

    Could anyone please tell me what’s going wrong here? I have tried this also for gtalk server and the result is same. Thanks in advance.

    The content of the corresponding /var/log/jaxl.log is as follows:

    [5472] 2011-04-02 06:16:23 – Jaxl stream not connected to jabber host, unable to send xmpp payload…

    [5477] 2011-04-02 06:17:24 – [[XMPPSend]] 185

    [5477] 2011-04-02 06:17:25 – [[XMPPGet]]

    [5477] 2011-04-02 06:17:25 – [[XMPPSend]] 51

    [5477] 2011-04-02 06:17:26 – [[XMPPGet]]

    [5477] 2011-04-02 06:17:38 – [[XMPPSend]] 16

    The jaxl.ini is as follows:

  19. Nil

    Not sure why message got truncated – probably there’s a limit on the size of a post. Anyhow, if any body has any suggestion on the above issue please let me know and if required I can send them my jaxl.ini and jaxl.log for review.


  20. Nitro


    Jaxl is good project, but It should be OS platform-independent and user should not be exposed to compile project. I’m tried run one of the example codes and I’m obtain some errors, look:

    Warning: touch() [function.touch]: Unable to create file /var/log/jaxl.log because No such file or directory in C:daneserwerhtdocsxmppcorejaxl.class.php on line 692

    Fatal error: Uncaught exception ‘JAXLException’ with message ‘Log file /var/log/jaxl.log doesn’t exists’ in C:daneserwerhtdocsxmppcorejaxl.class.php:692 Stack trace: #0 C:daneserwerhtdocsxmppappsendMessage.php(26): JAXL->__construct(Array) #1 {main} thrown in C:daneserwerhtdocsxmppcorejaxl.class.php on line 692

    1. i think these are minor errors which user should obviously be able to solve looking at the log content.
      However a future release will target to throw more user understandable error/warning to ease out first experience with library.

  21. Nitro

    I have Windows 7 with XAMPP Server. I try with Jaxl send message. I set correct value in app/sendMessage.php. I set correct path for Log and Pid Path [what do you need it?] in core/jaxl.class.php [maybe it’s not the best way], refresh page and … nothing happens, I not receive any messages.

    So what do I do?

  22. suneesh


    Using jaxl we are able to create and delete users in ejabberd server. But now we moved to tigase server as xmpp server, add and delete now not working. We are getting SASL authentification error. When i changed authType’=>’PLAIN’
    script hanging up…what we do? whether we are able to create users in tigase server using jaxl?

  23. Hi Abhinav,

    A dumb question. I used to host my bots on Imified.com. Now that the site is closing down, I need to create my own bots. Jaxl looks promising to me.

    Can you guide me how to start and read a level where a user can interact directly with my bot in Gtalk??


Comments are closed.