Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Jaxon integration for the Yii framework

This package integrates the Jaxon library into the Yii framework. It requires the version 2.0.11 or newer.


Add the following lines in the composer.json file, and run the composer update command.

"require": {
    "jaxon-php/jaxon-yii": "^4.0"

Or run the composer require jaxon-php/jaxon-yii command.

This package provides a filter that must be attached to routes to pages where the Jaxon features are enabled.

This is an example of a Yii controller using the Jaxon library.

namespace app\controllers;

use Yii;
use yii\web\Controller;
use Jaxon\Yii\Filter\JaxonConfigFilter;

class DemoController extends Controller
    public function behaviors()
        return [
                'class' => JaxonConfigFilter::class,
                'only' => ['index', 'jaxon'],

     * Process Jaxon ajax requests. This route must be the same that is set in the Jaxon config.
    public function actionJaxon()
        $jaxon = jaxon()->app();
            // Jaxon failed to find a plugin to process the request
            return; // Todo: return an error message

        return $jaxon->httpResponse();

     * Insert Jaxon js and css codes in the page.
    public function actionIndex()
        // Set the layout
        $this->layout = 'demo';
        // Get the Jaxon module
        $jaxon = jaxon()->app();

        return $this->render('index', [
            'jaxonCss' => $jaxon->css(),
            'jaxonJs' => $jaxon->js(),
            'jaxonScript' => $jaxon->script()

Before it prints the page, the controller calls the $jaxon->css(), $jaxon->js() and $jaxon->script() functions, to get the CSS and javascript codes generated by Jaxon which are inserted into the page.


The Jaxon library settings are defined in the @app/config/jaxon.php file, and separated into two sections. The options in the lib section are those of the Jaxon core library, while the options in the app sections are those of the Jaxon application.

The following options can be defined in the app section of the config file.

Name Description
directories An array of directory containing Jaxon application classes
views An array of directory containing Jaxon application views

By default, the views array is empty. Views are rendered from the framework default location. There's a single entry in the directories array with the following values.

Name Default value Description
directory @app/jaxon/classes The directory of the Jaxon classes
namespace \Jaxon\App The namespace of the Jaxon classes
separator . The separator in Jaxon class names
protected empty array Prevent Jaxon from exporting some methods


The Jaxon classes

The Jaxon classes can inherit from \Jaxon\App\CallableClass. By default, they are located in the @app/jaxon/ajax dir of the Yii application, and the associated namespace is \Jaxon\Ajax.

This is an example of a Jaxon class, defined in the @app/jaxon/ajax/HelloWorld.php file.

namespace Jaxon\Ajax;

class HelloWorld extends \Jaxon\App\CallableClass
    public function sayHello()
        $this->response->assign('div2', 'innerHTML', 'Hello World!');
        return $this->response;


  • Issue Tracker:
  • Source Code:


The package is licensed under the BSD license.


Jaxon library integration for the Yii framework







No packages published