PHPackages                             jaxon-php/jaxon-slim - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. jaxon-php/jaxon-slim

ActiveLibrary[Framework](/categories/framework)

jaxon-php/jaxon-slim
====================

Jaxon library integration for the Slim framework

v5.0.1(9mo ago)029BSD-3-ClausePHP

Since Apr 21Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/jaxon-php/jaxon-slim)[ Packagist](https://packagist.org/packages/jaxon-php/jaxon-slim)[ Docs](https://github.com/jaxon-php/jaxon-slim)[ RSS](/packages/jaxon-php-jaxon-slim/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (8)Used By (0)

Jaxon integration for the Slim Framework
========================================

[](#jaxon-integration-for-the-slim-framework)

This package is an extension to integrate the [Jaxon library](https://github.com/jaxon-php/jaxon-core) into the Slim framework. It works with Slim version 4.

Installation
------------

[](#installation)

Add the following lines in the `composer.json` file, and run the `composer update jaxon-php/` command.

```
"require": {
    "jaxon-php/jaxon-slim": "^5.0"
}
```

Routing and middlewares
-----------------------

[](#routing-and-middlewares)

This package provides two Jaxon PSR middlewares, one to load the Jaxon config, and the other to process Jaxon requests. The Jaxon config middleware must be attached to all the routes where the Jaxon features are enabled, while the later must be attached to the route that processes Jaxon requests.

```
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
use Slim\Factory\AppFactory;
use Slim\Psr7\Response;

use function jaxon;

require __DIR__ . '/../vendor/autoload.php';

$app = AppFactory::create();

// Jaxon middleware to load config
// Set a container if you need to use its services in Jaxon classes.
// Set a logger if you need to send messages to your logs in Jaxon classes.
$jaxonConfigMiddleware = function(Request $request, RequestHandler $handler) {
    return jaxon()->psr()
        // Uncomment the following line to set a container
        // ->container($container)
        // Uncomment the following line to set a logger
        // ->logger($logger)
        ->config(__DIR__ . '/../config/jaxon.php')->process($request, $handler);
};

// Process Jaxon ajax requests
$app->group('/', function() use($app) {
    // Register the app container with the Jaxon library.
    if(($container = $app->getContainer()) !== null)
    {
        jaxon()->app()->setContainer($container);
    }

    // Jaxon middleware to process ajax requests
    $jaxonAjaxMiddleware = function(Request $request, RequestHandler $handler) {
        return jaxon()->psr()->ajax()->process($request, $handler);
    };

    $app->post('/jaxon', function($request, $response) {
        // Todo: return an error. Jaxon could not find a plugin to process the request.
    })->add($jaxonAjaxMiddleware);

    // Insert Jaxon codes in a page
    $app->get('/', function($request, $response) {
        // Display a page with Jaxon js and css codes.
        $jaxon = jaxon()−>app();
        $css = $jaxon->css();
        $js = $jaxon->js();
        $script = $jaxon->script();
        // Display the page
        ...
    });
})->add($jaxonConfigMiddleware);
```

Configuration
-------------

[](#configuration)

The above example bootstraps the library from the `config/jaxon.php` file. It must contain both the `app` and `lib` sections defined in the documentation ().

An example is presented in the `config/config.php` file of this repo.

Setting the view renderer
-------------------------

[](#setting-the-view-renderer)

The Slim Framework provides two components for view rendering, and both can be used with the [Jaxon view renderer](https://www.jaxon-php.org/docs/v3x/advanced/views.html).

The [Twig-View](https://github.com/slimphp/Twig-View) component displays Twig views.

```
use Jaxon\Slim\Helper;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
use Slim\Views\TwigMiddleware;

// Add Twig-View Middleware
$twig = Helper::twig(__DIR__ . '/../templates', ['cache' => false]);
$app->add(TwigMiddleware::create($app, $twig));

$jaxonConfigMiddleware = function(Request $request, RequestHandler $handler) {
    return jaxon()->psr()
        ->view('twig', '.html.twig', function() use($request) {
            return Helper::twigView($request);
        })
        ->config(__DIR__ . '/../jaxon/config.php')
        ->process($request, $handler);
};
```

The [PHP-View](https://github.com/slimphp/PHP-View) component displays PHP views.

```
$jaxonConfigMiddleware = function(Request $request, RequestHandler $handler) {
    return jaxon()->psr()
        ->view('php', '.php', function() {
            return Helper::phpView(__DIR__ . '/../templates');
        })
        ->config(__DIR__ . '/../jaxon/config.php')
        ->process($request, $handler);
};
```

Twig functions
--------------

[](#twig-functions)

This extension provides the following Twig functions to insert Jaxon js and css codes in the pages that need to show Jaxon related content.

```
// templates/demo/index.html.twig

{{ jxnCss() }}

{{ jxnJs() }}

{{ jxnScript() }}
```

Call factories
--------------

[](#call-factories)

This extension registers the following Twig functions for Jaxon [call factories](https://www.jaxon-php.org/docs/v5x/ui-features/call-factories.html) functions.

Note

In the following examples, the `rqAppTest` template variable is set to the value `rq(Demo\Ajax\App\AppTest::class)`.

The `jxnBind` function attaches a UI component to a DOM element, while the `jxnHtml` function displays a component HTML code in a view.

```

        {{ jxnHtml(rqAppTest) }}

```

The `jxnPagination` function displays pagination links in a view.

```

```

The `jxnOn` function binds an event on a DOM element to a Javascript call defined with a `call factory`.

```

        Black
        Red
        Green
        Blue

```

The `jxnClick` function is a shortcut to define a handler for the `click` event.

```
    Click me
```

The `jxnEvent` function defines a set of events handlers on the children of a DOM element, using `jQuery` selectors.

```

                Black
                Red
                Green
                Blue

                Black
                Red
                Green
                Blue

```

The `jxnEvent` function takes as parameter an array in which each entry is an array with a `jQuery` selector, an event and a `call factory`.

Contribute
----------

[](#contribute)

- Issue Tracker: github.com/jaxon-php/jaxon-slim/issues
- Source Code: github.com/jaxon-php/jaxon-slim

License
-------

[](#license)

The package is licensed under the BSD license.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance56

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~198 days

Recently: every ~272 days

Total

7

Last Release

290d ago

Major Versions

v4.0.0 → v5.0.0-beta.12025-06-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebb668d7515d81741c86e42cf3194f5623636fbb15dd5412e26ea8320865d229?d=identicon)[lagdo](/maintainers/lagdo)

---

Top Contributors

[![feuzeu](https://avatars.githubusercontent.com/u/15174329?v=4)](https://github.com/feuzeu "feuzeu (23 commits)")

---

Tags

phpslimajaxJaxon

### Embed Badge

![Health badge](/badges/jaxon-php-jaxon-slim/health.svg)

```
[![Health](https://phpackages.com/badges/jaxon-php-jaxon-slim/health.svg)](https://phpackages.com/packages/jaxon-php-jaxon-slim)
```

###  Alternatives

[jaxon-php/jaxon-laravel

Jaxon library integration for the Laravel framework

101.8k4](/packages/jaxon-php-jaxon-laravel)[patricksavalle/slim-rest-api

Production-grade REST-API App-class for PHP SLIM, in production on https://zaplog.pro (https://api.zaplog.pro/v1)

101.4k](/packages/patricksavalle-slim-rest-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
