{"id":20934465,"url":"https://github.com/jaxon-php/jaxon-slim","last_synced_at":"2026-01-31T13:08:13.856Z","repository":{"id":50616674,"uuid":"483765144","full_name":"jaxon-php/jaxon-slim","owner":"jaxon-php","description":"Jaxon library integration for the Slim micro framework","archived":false,"fork":false,"pushed_at":"2025-07-23T14:53:33.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-05T03:23:47.506Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaxon-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-20T18:14:00.000Z","updated_at":"2025-07-23T14:48:16.000Z","dependencies_parsed_at":"2024-11-30T15:22:22.894Z","dependency_job_id":"1b5ec117-a2b2-433e-a5d5-818fb4f8c6d6","html_url":"https://github.com/jaxon-php/jaxon-slim","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"7c428f2f977965d1911ff1f4944d318c7a077c12"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jaxon-php/jaxon-slim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-slim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-slim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-slim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-slim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaxon-php","download_url":"https://codeload.github.com/jaxon-php/jaxon-slim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-slim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28943992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T13:02:32.153Z","status":"ssl_error","status_checked_at":"2026-01-31T13:00:07.528Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T22:09:27.608Z","updated_at":"2026-01-31T13:08:13.848Z","avatar_url":"https://github.com/jaxon-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Jaxon integration for the Slim Framework\n========================================\n\nThis package is an extension to integrate the [Jaxon library](https://github.com/jaxon-php/jaxon-core) into the Slim framework.\nIt works with Slim version 4.\n\nInstallation\n------------\n\nAdd the following lines in the `composer.json` file, and run the `composer update jaxon-php/` command.\n\n```json\n\"require\": {\n    \"jaxon-php/jaxon-slim\": \"^5.0\"\n}\n```\n\nRouting and middlewares\n-----------------------\n\nThis package provides two Jaxon PSR middlewares, one to load the Jaxon config, and the other to process Jaxon requests.\nThe Jaxon config middleware must be attached to all the routes where the Jaxon features are enabled,\nwhile the later must be attached to the route that processes Jaxon requests.\n\n```php\nuse Psr\\Http\\Message\\ServerRequestInterface as Request;\nuse Psr\\Http\\Server\\RequestHandlerInterface as RequestHandler;\nuse Slim\\Factory\\AppFactory;\nuse Slim\\Psr7\\Response;\n\nuse function jaxon;\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\n$app = AppFactory::create();\n\n// Jaxon middleware to load config\n// Set a container if you need to use its services in Jaxon classes.\n// Set a logger if you need to send messages to your logs in Jaxon classes.\n$jaxonConfigMiddleware = function(Request $request, RequestHandler $handler) {\n    return jaxon()-\u003epsr()\n        // Uncomment the following line to set a container\n        // -\u003econtainer($container)\n        // Uncomment the following line to set a logger\n        // -\u003elogger($logger)\n        -\u003econfig(__DIR__ . '/../config/jaxon.php')-\u003eprocess($request, $handler);\n};\n\n// Process Jaxon ajax requests\n$app-\u003egroup('/', function() use($app) {\n    // Register the app container with the Jaxon library.\n    if(($container = $app-\u003egetContainer()) !== null)\n    {\n        jaxon()-\u003eapp()-\u003esetContainer($container);\n    }\n\n    // Jaxon middleware to process ajax requests\n    $jaxonAjaxMiddleware = function(Request $request, RequestHandler $handler) {\n        return jaxon()-\u003epsr()-\u003eajax()-\u003eprocess($request, $handler);\n    };\n\n    $app-\u003epost('/jaxon', function($request, $response) {\n        // Todo: return an error. Jaxon could not find a plugin to process the request.\n    })-\u003eadd($jaxonAjaxMiddleware);\n\n    // Insert Jaxon codes in a page\n    $app-\u003eget('/', function($request, $response) {\n        // Display a page with Jaxon js and css codes.\n        $jaxon = jaxon()−\u003eapp();\n        $css = $jaxon-\u003ecss();\n        $js = $jaxon-\u003ejs();\n        $script = $jaxon-\u003escript();\n        // Display the page\n        ...\n    });\n})-\u003eadd($jaxonConfigMiddleware);\n```\n\nConfiguration\n-------------\n\nThe above example bootstraps the library from the `config/jaxon.php` file.\nIt must contain both the `app` and `lib` sections defined in the documentation (https://www.jaxon-php.org/docs/v5x/about/configuration.html).\n\nAn example is presented in the `config/config.php` file of this repo.\n\nSetting the view renderer\n-------------------------\n\nThe Slim Framework provides two components for view rendering, and both can be used with the\n[Jaxon view renderer](https://www.jaxon-php.org/docs/v3x/advanced/views.html).\n\nThe [Twig-View](https://github.com/slimphp/Twig-View) component displays Twig views.\n\n```php\nuse Jaxon\\Slim\\Helper;\nuse Psr\\Http\\Message\\ServerRequestInterface as Request;\nuse Psr\\Http\\Server\\RequestHandlerInterface as RequestHandler;\nuse Slim\\Views\\TwigMiddleware;\n\n// Add Twig-View Middleware\n$twig = Helper::twig(__DIR__ . '/../templates', ['cache' =\u003e false]);\n$app-\u003eadd(TwigMiddleware::create($app, $twig));\n\n$jaxonConfigMiddleware = function(Request $request, RequestHandler $handler) {\n    return jaxon()-\u003epsr()\n        -\u003eview('twig', '.html.twig', function() use($request) {\n            return Helper::twigView($request);\n        })\n        -\u003econfig(__DIR__ . '/../jaxon/config.php')\n        -\u003eprocess($request, $handler);\n};\n```\n\nThe [PHP-View](https://github.com/slimphp/PHP-View) component displays PHP views.\n\n```php\n$jaxonConfigMiddleware = function(Request $request, RequestHandler $handler) {\n    return jaxon()-\u003epsr()\n        -\u003eview('php', '.php', function() {\n            return Helper::phpView(__DIR__ . '/../templates');\n        })\n        -\u003econfig(__DIR__ . '/../jaxon/config.php')\n        -\u003eprocess($request, $handler);\n};\n```\n\nTwig functions\n--------------\n\nThis extension provides the following Twig functions to insert Jaxon js and css codes in the pages that need to show Jaxon related content.\n\n```php\n// templates/demo/index.html.twig\n\n\u003c!-- In page header --\u003e\n{{ jxnCss() }}\n\u003c/head\u003e\n\n\u003cbody\u003e\n\n\u003c!-- Page content here --\u003e\n\n\u003c/body\u003e\n\n\u003c!-- In page footer --\u003e\n{{ jxnJs() }}\n\n{{ jxnScript() }}\n```\n\nCall factories\n--------------\n\nThis extension registers the following Twig functions for Jaxon [call factories](https://www.jaxon-php.org/docs/v5x/ui-features/call-factories.html) functions.\n\n\u003e [!NOTE]\n\u003e In the following examples, the `rqAppTest` template variable is set to the value `rq(Demo\\Ajax\\App\\AppTest::class)`.\n\nThe `jxnBind` function attaches a UI component to a DOM element, while the `jxnHtml` function displays a component HTML code in a view.\n\n```php\n    \u003cdiv class=\"col-md-12\" {{ jxnBind(rqAppTest) }}\u003e\n        {{ jxnHtml(rqAppTest) }}\n    \u003c/div\u003e\n```\n\nThe `jxnPagination` function displays pagination links in a view.\n\n```php\n    \u003cdiv class=\"col-md-12\" {{ jxnPagination(rqAppTest) }}\u003e\n    \u003c/div\u003e\n```\n\nThe `jxnOn` function binds an event on a DOM element to a Javascript call defined with a `call factory`.\n\n```php\n    \u003cselect class=\"form-select\"\n        {{ jxnOn('change', rqAppTest.setColor(jq().val())) }}\u003e\n        \u003coption value=\"black\" selected=\"selected\"\u003eBlack\u003c/option\u003e\n        \u003coption value=\"red\"\u003eRed\u003c/option\u003e\n        \u003coption value=\"green\"\u003eGreen\u003c/option\u003e\n        \u003coption value=\"blue\"\u003eBlue\u003c/option\u003e\n    \u003c/select\u003e\n```\n\nThe `jxnClick` function is a shortcut to define a handler for the `click` event.\n\n```php\n    \u003cbutton type=\"button\" class=\"btn btn-primary\"\n        {{ jxnClick(rqAppTest.sayHello(true)) }}\u003eClick me\u003c/button\u003e\n```\n\nThe `jxnEvent` function defines a set of events handlers on the children of a DOM element, using `jQuery` selectors.\n\n```php\n    \u003cdiv class=\"row\" {{ jxnEvent([\n        ['.app-color-choice', 'change', rqAppTest.setColor(jq().val())]\n        ['.ext-color-choice', 'change', rqExtTest.setColor(jq().val())]\n    ]) }}\u003e\n        \u003cdiv class=\"col-md-12\"\u003e\n            \u003cselect class=\"form-control app-color-choice\"\u003e\n                \u003coption value=\"black\" selected=\"selected\"\u003eBlack\u003c/option\u003e\n                \u003coption value=\"red\"\u003eRed\u003c/option\u003e\n                \u003coption value=\"green\"\u003eGreen\u003c/option\u003e\n                \u003coption value=\"blue\"\u003eBlue\u003c/option\u003e\n            \u003c/select\u003e\n        \u003c/div\u003e\n        \u003cdiv class=\"col-md-12\"\u003e\n            \u003cselect class=\"form-control ext-color-choice\"\u003e\n                \u003coption value=\"black\" selected=\"selected\"\u003eBlack\u003c/option\u003e\n                \u003coption value=\"red\"\u003eRed\u003c/option\u003e\n                \u003coption value=\"green\"\u003eGreen\u003c/option\u003e\n                \u003coption value=\"blue\"\u003eBlue\u003c/option\u003e\n            \u003c/select\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n```\n\nThe `jxnEvent` function takes as parameter an array in which each entry is an array with a `jQuery` selector, an event and a `call factory`.\n\nContribute\n----------\n\n- Issue Tracker: github.com/jaxon-php/jaxon-slim/issues\n- Source Code: github.com/jaxon-php/jaxon-slim\n\nLicense\n-------\n\nThe package is licensed under the BSD license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxon-php%2Fjaxon-slim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaxon-php%2Fjaxon-slim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxon-php%2Fjaxon-slim/lists"}