(2 replies, posted in Announcements)

romandukhanin wrote:

//We dropped the HTML api docs due to our new online API docs that are updated frequently.

Its not available now sad

Where can I get it?

You may want to check out this fork of Xajax http://www.jaxon-php.org.


(24 replies, posted in Announcements)


Right now I'm focusing on creating plugins for the most common Javascript libraries and PHP frameworks.
I'd be very happy to provide you with the necessary help if you decide to write your own plugin. It is easy, and there are many plugins in the github repo you can start from.



(3 replies, posted in Announcements)


architekt_berlin wrote:


Did the project die after moving? Thats sad...


(24 replies, posted in Announcements)

I've contributed some changes I made to the Xajax library for some projects I've worked on https://github.com/lagdo/xajax-core.

My first intention was to make it the next version of Xajax, but after a while I found out that the best thing to do was to take the project to another direction.
So I forked Xajax https://github.com/jaxon-php/jaxon-core. The website of the new library is still under conctruction https://www.jaxon-php.org.

architekt_berlin wrote:


I think the developers should now be brave enough to release a 0.6 stable version. To keep a version as beta over decade is not appropriate. Most of the bugs should have been reported in the last five years. At some time, the developers must come forward bravely and declare that there are no bugs any more i.e. in other words we paid attention to known bugs.

The first part of the english docs are online http://xajax.lagdo-software.net/docs/en.

Anyone speaking french here?

The french docs are online http://xajax.lagdo-software.net/docs/fr/, and the english docs are coming soon.


(1 replies, posted in Examples)


I've created a skeleton for the CodeIgniter package on Github: https://github.com/lagdo/xajax-codeigniter.
The package includes code from the my Laravel package an from the examples published here.

Now there are some decisions we need to take before going any further:

1. The location and a namespace of the Xajax classes.
Once this is set, the framework will be able to automatically parse the specified directory and register all the Xajax classes it contains. The addClassDir() and registerClasses() methods were added to the Xajax class to ease the implementation of this feature.
I would suggest the application/xajax as default directory, and \Xajax\CI as namespace.

2. The location and the format of the config file.
The config file shall provide options both for the Xajax library and the user application. The user application options include the Xajax path and namespace defined above.

As the CI Xajax library automatically reads the config file, and sets the specified options, the Xajax_Controller provided in the package works as is, without any change.

Hi Ed,

Thanks for your help.
IMHO, MkDocs is a great tool to build the documentation.
It produces static HTML files from markdown-formatted text files, which can then be published on ReadTheDocs or Github Pages.

Regarding the doc content, having a separate Github project only for doc files seems to be a good idea too, as we could have not only the core package, but also some plugins and framework integration packages documented as well, all in a single project.


Hi all,

The API documentation of the library is now online.
Check it out at http://xajax.lagdo-software.net/docs/api/



The new library plays nicely with PHP7.


Hello Ed,

Your sayHello() is actually a method, and thus cannot be registered with its function name.

You should either register the method with an alias

$this->xajax->register(XAJAX_FUNCTION,array('sayHello', $this, 'sayHello'));

Or declare the method in a separate class and register the class.

I've merged the xajax-config package into xajax-core. The xajax-config package implements functions to read the config options of the Xajax library from files in Php, Json and Yaml formats. So by now this feature is available in the xajax-core library out of the box.

I've added a new Config File example where the Xajax config is read from a Yaml file.
I've also modified the  Hello World Class and  Autoload Separated examples to read config resp. from a Php file and a Json file.

The Xajax classes cannot be found because the autoload is missing.

require (APPPATH . '../vendor/autoload.php');
moo wrote:

Hello All,

I'm trying to write a library for the newly resurrected Xajax project (from Thierry Feuzeu)...

and I'm coming up short due to my inexperience in writing CodeIgniter Libraries and with PHP namespacing.

Could anyone offer some thoughts on how to make this work? (see's Thierry's example code: https://github.com/lagdo/xajax-examples … /hello.php)

Here's what I've got so far, and it definitely instantiates an xajax object, of which I can access at least the getVersion() method from inside a CodeIgniter controller method, but I can't figure out how to write the Library to access other basics (see errors in __construct() ):
( output: http://triv.ath.cx/ci3/ )

So, I'm at a loss as to what to do next... any advice?

CodeIgniter 3 Library:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require (APPPATH . '../vendor/autoload.php');

use Xajax\Xajax;
use Xajax\Response\Response;
use Xajax\Request\Factory as xr;

class CI_Xajax {

  public $xajax = '';

    public function __construct()

    $this->xajax = Xajax::getInstance();
//        $this->_ci   =& get_instance();
    $this->xajax->setOption('core.debug.on', true);
    $this->xajax->setOption('core.prefix.function', 'xajax_');

CodeIgniter 3 Welcome Controller:

defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

    public function __construct()

        $this->load->library(array('CI_Xajax', 'session'));

//    $this->ci_xajax->xajax->register(Xajax::USER_FUNCTION, 'hello');
//    Fatal error: Class 'Xajax' not found in /var/www/html/ci3/application/controllers/Welcome.php on line 12

//    $this->ci_xajax->xajax->register(CI_Xajax::USER_FUNCTION, 'hello');
//    Fatal error: Undefined class constant 'USER_FUNCTION' in /var/www/html/ci3/application/controllers/Welcome.php on line 15


    public function index()
    $viewData = '';
    $viewData['XjxVersion'] = $this->ci_xajax->xajax->getVersion();

    public function hello() {

Based on the above guidelines, I can suggest the following changes to your code

class CI_Xajax extends CI_Controller
// ...

class Welcome extends CI_Xajax
// ...

Also don't forget to declare the classes at top of your classes

use Xajax\Xajax;
use Xajax\Response\Response;
use Xajax\Request\Factory as xr;


Although I've never used the CodeIgniter framework, IMO the main guidelines for integrating the Xajax library are the same as for other frameworks. So let me share what I'm currently doing with Laravel.

1. Choose a route for the Xajax request processing.

2. Choose a location and a namespace for the Xajax classes of the application. This step is optional.

3. Create an Xajax controller with at least two functions:
  - init(boolean): where the Xajax objects are created, configured and the Xajax classes are registered. The boolean parameter allows to skip the class registration.
Set the route chosen at step 1 as the 'core.request.uri' option of the Xajax library.

$xajax->setOption('core.request.uri', $route);

If a directory was chosen at step 2, all the classes inside can be registered here with two calls:

$xajax->addClassDir($sPath, $sNamespace);

  - process(): where the Xajax request is processed.
Here's a sample code for the process function.

    public function process()
        $this->init(false); // There's no need to register all your classes when processing a single request
        // Process Ajax request
        $xajax = Xajax::getInstance():

The Xajax controller may inherit from the base controller provided by the framework.

4. Redirect the route chosen in step 1 to the process() function.

5. Make any controller in your app serving Xajax powered pages inherit from the Xajax controller. This class must call the init() function above with its parameter set to true, before printing the page.

6. Output the Xajax generated code in your views using the $xajax->getJavascript(), $xajax->getJsInclude() and $xajax->getCssInclude() calls.

7. Take a fresh drink to relax after this hard work.

The steps 1 to 3, and even 4, can be implemented in a separated package, so the developer only need to make a few calls in its controller.
In this case, the config options to be set in the init() function may be loaded from the config system provided by the framework.

adiev86 wrote:

Thank you so Much! Greetings from Peru!

You are welcome!!


The new Xajax library has reached what I consider an important milestone. All the features I planned in the core package are implemented.
I'm going to focus now on testing and documenting the library, making a few more plugins, and integrating to a few frameworks.

As the first stable release is getting closer, I'm now thinking of moving to the version number to 1.0.0, since there has been so many important changes on the library.

I have made some changes to the xajax-examples package.

A third-party autoloader is now used in the autoload-disabled.php example, so it does not need to be modified anymore to work.
There are sample PHP codes in the example pages, to show how they are implemented.

I've installed the xajax-examples package on a demo server online http://xajax.lagdo-software.net.

I started working on a recode of the Xajax library a few weeks ago, and today, I am pleased to present you with the new Xajax library.
The main goal was to use the latest PHP features to make the Xajax library extensible and modular.

So what is it about?

The new Xajax is modular and extensible

The library is now separated into two main packages.

The first package is the core PHP library https://github.com/lagdo/xajax-core. It provides the main Xajax class, which is now named Xajax, and implements the functionalities needed to export PHP classes to javascript, and handle the Xajax requests and responses. All the classes in this package are in the Xajax namespace.

The second package contains the javascript files of the library https://github.com/lagdo/xajax-js. Having a javascript only package will later allow to use an open source CDN like https://cdnjs.com or https://www.jsdelivr.com to deliver the files. By default, the Xajax core library gets the files from a server of mine, which offers HTTP and HTTPS access (thanks to Let's Encrypt). Of course, they can also be installed on a private server.

This two packages are the minimum requirement to create an Xajax application, however the library can be extended with additional plugins.
I have created three plugins, which are used in the sample codes in the xajax-examples package https://github.com/lagdo/xajax-examples.

https://github.com/lagdo/xajax-toastr: this package implements javascript notifications with the Toastr JQuery plugin https://github.com/CodeSeven/toastr.
https://github.com/lagdo/xajax-pgwjs: this package implements responsive modal dialog with the PgwModal library http://pgwjs.com/pgwmodal.
https://github.com/lagdo/xajax-bootstrap: this package implements modal dialog with the Twitter Bootstrap library. It requires to manually install the Twitter Bootstrap javascript and CSS files to work properly.

What's new is this package

First of all, the new Xajax library is namespaced, uses PSR-4 autoloading, and installs with Composer.
Some features are deprecated, some others, like javascript code generation (see the examples below) are recoded, and some new features are added.

The new feature I consider the most important is the ability to automatically register all the classes in one or more directories, each directory being associated to a namespace or not.
When exporting PHP classes from a directory, the generated javascript classes are named accordingly. In a directory D, the class A in the file D/S/A.php will generate the javascript class S.A, and if the associated namespace is N, the generated javascript class will be N.S.A. As we'll see in the examples below, the new Xajax library also takes advantage of PHP autoloading to optimize request processing.
This feature makes the Xajax library more suitable for use in modular applications with hundreds of classes.


Samples code demonstrating the use of the new Xajax library are provided in the xajax-examples package: https://github.com/lagdo/xajax-examples. All examples are based on the helloword.php example in the original Xajax repository https://github.com/Xajax/Xajax/blob/mas … oworld.php. The installation process is described in the homepage of the repository. After the examples are installed, enter the name of any file in the browser to see the result.

- hello.php
This example shows how to export a function with Xajax.

- class.php
This example shows how to export a class with Xajax.

- merge.php
This example shows how to export the generated javascript code in an external file, which is then loaded into the webpage.
You'll need to create the "deferred" directory, and adapt the parameters of the call mergeJavascript() function to your webserver configuration for this example to work.
The compression of the generated javascript code is not yet implemented.

- plugins.php
The example shows the use of Xajax plugins, by adding javascript notifications and modal windows to the class.php example with the xajax-toastr, xajax-pgwjs and xajax-bootstrap packages.
Using an Xajax plugin is very simple. After a plugin is installed with Composer, its automatically registers into the Xajax core library. It can then be accessed both in the Xajax main object, for configuration, and in the Xajax response object, to provide additional functionalities to the application.

- classdirs.php
This example shows how to automatically register all the PHP classes in a set of directories.
The classes in this example are not namespaced, thus they all need to have different names, even if they are in different subdirs.

- namespaces.php
This example shows how to automatically register all the classes in a set of directories with namespaces.
The namespace is prepended to the generated javascript class names, and PHP classes in different subdirs can have the same name.

- autoload-default.php
This example shows how to optimize Xajax requests processing with autoloading.
In all the examples above, an instance of all exported Xajax classes is created when processing a request, while only an instance of the requested class is needed. In an application with a high number of classes, this can cause performance issues.
In this example, the Xajax classes are not registered when processing a request. However, the Xajax library is smart enough to detect that the required class is missing, and load only the necessary file.

- autoload-composer.php
This example illustrates the use of the Composer autoloader.
By default, the Xajax library implements a simple autoloading mechanism by require_once'ing the corresponding PHP file for each missing class. When provided with the Composer autoloader, the Xajax library registers all directories with a namespace into the PSR-4 autoloader, and it registers all the classes in directories with no namespace into the classmap autoloader.

- autoload-disabled.php
In this example the autoloading is disabled in the Xajax library.
The developer then needs to provides its own autoloading, otherwise the Xajax library will raise an error at any attempt to register classes from a directory.
This example will not work until the autoloading is setup.

What's next?

This version of the package is still an early alpha release, not yet suitable for use in production.
There is still much work to do, and in my point of view the most important ones are:
- Check security, mainly for input data.
- Write tests.
- Write documentation and tutorials.

All ideas, all comments and any help are welcome.
The plugin interface is quite stable now, so anyone willing to write a plugin is encouraged to do so.



(1 replies, posted in Announcements)

Hi all,

I would like to share the work I've done on the Xajax library with the community.
I've been using this package for years now, and for me there is no such other package for building Ajax applications rapidly.

I'm currently using Xajax in a Laravel 5.1 application running on PHP7, so I needed to make some changes to make it work with PHP7, and to integrate to the Laravel framework.

The modified Xajax package is here: https://github.com/lagdo/xajax, and this is a summary of the changes I made.
- All the constructors are renamed from class name to __construct.
- The references are removed where they are not really needed.
- The XAJAX_PAGE_NUMBER parameter and the setPageNumber() method are added to the request object to ease the creation of pagination links.
- The ReflexionClass is used to get the name and methods of callable objects.
- Some methods of a callable object can be excluded from the generated javascript code.
- A classpath can be defined for each registered callable object, allowing the creation o

This last feature is one of the most important, as it has allowed me to organise the PHP classes of my Xajax app into a multilevel subdirectory hierarchy. Unfortunately, for now this feature is available only in the Xajax package for the Laravel framework, which is found here: https://github.com/lagdo/lajax.

This package leverages the unique features of Laravel to automatically create and initialize the Xajax object, and load all the classes from a defined directory. Moreover, only the required class is loaded when processing a request, allowing to achieve best performances. Of course, the Xajax classes can be organised into multiple subdirectories, and they can even be namespaced. This way, it is much more easy to build bigger applications with Xajax.

As I was thinking about how to allow the use of classpaths and namespacing right in the Xajax library, I came to the conclusion that the library needs some recoding.
The goal is to take advantage of the advanced features of PHP like namespacing, autoloading, composer, to make the Xajax library simpler to install and use, modular and extensible.
I've started working on the new packages, which I'll introduce here in a few days.

So stay tuned!