Search by

webware / webware-htmx

tyrsson

Provides HTMX support via laminas-view to webware applications.

Package info

github.com/webinertia/webware-htmx

pkg:composer/webware/webware-htmx

Statistics

Installs: 1 438

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 1

1.0.0-alpha.2 2026-10-01 11:57 UTC

This package is auto-updated.

Last update: 2026-10-03 15:43:35 UTC


README

Provides HTMX support via laminas-view to webware applications: AJAX request detection middleware, HTMX response headers and triggers, and a body-aware laminas-view renderer.

PHP Version Latest Version License Required CI codecov Mutation testing badge

Installation

composer require webware/webware-htmx

Register the ConfigProvider in your Mezzio application config aggregator:

Webware\Htmx\ConfigProvider::class,

What it provides

  • DetectAjaxRequestMiddleware — detects HTMX requests and filters the incoming server request.
  • DisableBodyMiddleware — disables the body layer for HTMX requests.
  • Webware\Htmx\Response\Header — HTMX response header helpers (HX-Trigger, HX-Redirect, …).
  • Webware\Htmx\View\LaminasRenderer — a laminas-view renderer with body/layout layering, registered as the default TemplateRendererInterface.
  • A baseline body template at templates/default/body/default.phtml, published as body::default.

Configuration

Two keys, one value each, and both values name template addresses rather than paths:

Key Meaning
templates.body the address of the body layer, e.g. body::default
templates.layout the address of the layout, e.g. layout::default

Neither is required: with no templates.body the content renders alone, and with no templates.layout nothing wraps it.

The package publishes body::default for its own baseline template in templates.map. Overriding it needs no special placement: a map's key is the address, string keys merge later-wins, so a provider merged after this package's — an application's own ConfigProvider, a config file, or a theme — replaces the value for anyone asking for that address.

With webware/webware-theme installed, both addresses resolve through the theme, so body::default can point at any theme's file without this package knowing themes exist.