Fork me on GitHub

Extending the Response object with plugins


A Jaxon response plugin enriches the Jaxon\Response\response class with new functions.

Installation

To install a Jaxon Response plugin, install the corresponding package with Composer. Once installed, the plugin is automatically registered with the Jaxon library, and its CSS and javascript are automatically added to those generated by the library.

Usage

A Jaxon response plugin has a name, which must be unique across the application. This name provides access to an instance of the plugin from an instance of Jaxon\Response\Response.

Configuration

The response plugins are configured in the same way as the Jaxon library, except that the parameter names are prefixed with the name of the plugin.

The documentation of each plugin provides a list of its configuration settings.

Example

The jaxon-dialogs plugin for the version 2 of Jaxon adds notifications to an application using various javascript libraries, including Toastr.

To install it, add its package to the composer.json file.

"require": {
    "jaxon-php/jaxon-dialogs": "~4.0"
}

Then configure the package so it use the Toastr library.

    $jaxon->setOptions('dialogs.default.alert', 'toastr');

Once installed and configured, the javascript and css files of the Toastr library are loaded into the HTML page, and the methods of the plugin can be called from Jaxon functions.

use function Jaxon\jaxon;

class MyClass
{
    public function myMethod()
    {
        $response = jaxon()->newResponse();
        $response->dialog->success("You are now using the Toastr Notification plugin!!");
    }
}

The $response->dialog call is the short for $response->plugin('dialog').