xp-forge/htmx

HTMX integration for XP web frontends

v0.3.0 2024-03-29 12:02 UTC

This package is auto-updated.

Last update: 2024-10-29 13:35:31 UTC


README

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.4+ Supports PHP 8.0+ Latest Stable Version

HTMX Integration

Authentication

Wrap any authentication flow in a HtmxFlow to ensure authentication does not redirect but instead yields an error code and triggers an event:

+ use web\frontend\HtmxFlow;

- $auth= new SessionBased($flow, $sessions);
+ $auth= new SessionBased(new HtmxFlow($flow), $sessions);

Handle this inside JavaScript with something along the lines of the following:

window.addEventListener('authenticationexpired', e => {
  if (confirm('Authentication expired. Do you want to re-authenticate?')) {
    window.location.reload();
  }
});