xp-forge / htmx
HTMX integration for XP web frontends
v0.3.0
2024-03-29 12:02 UTC
Requires
- php: >=7.4.0
- xp-forge/frontend: ^6.0 | ^5.0
- xp-forge/web-auth: ^5.0 | ^4.0 | ^3.7
- xp-framework/core: ^12.0 | ^11.0 | ^10.0
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
README
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(); } });