CakePHP with Stimulus.js
A demo showing Stimulus and CakePHP 3.x working together.
As example, it shows partial page rendering; replacing/adding server-side generated HTML snippets on the web page.
Why Stimulus
What Stimulus does can be done with other javascript libraries as well, but what I like is:
- The HTML is not cluttered with script code or vague class names
- It’s clear which controllers are used and where (data-controller attribute)
- It’s clear where the controller will make changes (data-target attribute)
- It’s clear what triggers the controller (data-action attribute)
- The controllers have a life-cycle and are automatically connected and disconnected if the DOM-tree is modified.