mix phtmx.install (Phtmx v0.2.0)

Copy Markdown View Source

Installs phtmx into a Phoenix 1.8+ application.

mix igniter.install phtmx

It performs four edits, each idempotent and each degrading to a printed notice (rather than a guessed edit) if it can't confidently locate the anchor — you always review the full diff before anything is written:

  1. adds plug Phtmx.Plug to the :browser router pipeline;
  2. adds import Phtmx.Response to the web module's controller/0;
  3. adds the CSRF hx-headers attribute to <body> in the root layout;
  4. vendors htmx.min.js into assets/vendor/ and imports it from assets/js/app.js.

Options

  • --pipeline - the router pipeline to add the plug to (default: browser)
  • --htmx-version - the htmx version to vendor (default: 2.0.4)
  • --skip-asset-fetch - don't download htmx; still wires the app.js import and prints a notice so you can vendor it yourself (useful offline or in CI)