Fork me on GitHub

Packages


The packages were introduced in the version 3 of Jaxon. They provide a complete set of features to a Jaxon based application, which users can access within a dedicated page.

The unique advantage of Jaxon packages is that they contain all the components required to implement the features they aim to provide, including frontend and backend, while still being compatible with any PHP framework or application.

Installation

A package is installed with Composer, like any other Jaxon plugin. Then, it must be declared in the Jaxon configuration, and its CSS and javascript code will automatically be included in those generated by the Jaxon library.

Configuration

The configuration of a package is defined in the app section of the Jaxon configuration. The key is the name of the package main class, and the parameters depend on the package features.

Here's an example configuration of the jaxon-supervisor package.

    'app' => [
        // Other config options
        // ...
        'packages' => [
            Lagdo\Supervisor\Package::class => [
                'servers' => [
                    'first_server' => [
                        'url' => 'http://192.168.1.10',
                        'port' => '9001',
                    ],
                    'second_server' => [
                        'url' => 'http://192.168.1.11',
                        'port' => '9001',
                    ],
                ],
            ],
        ],
    ],

Usage

A Jaxon package provides a user interface which is to be displayed in a page of the application. Its HTML code must therefore be included in the page code, and a javascript code can optionally be executed on page loading.

The instance of the package main class is returned by a call to jaxon()->package($packageClassName). The HTML code is returned by the getHtml() method. When the ready() method is called, the Jaxon library includes the package javascript code in the page. It is also possible to include this code directly using a call to getReadyScript().