hello-sebastian/hello-stimulus-bundle
Symfony bundle that brings Stimulus controllers into your PHP app, handling controller discovery, asset registration and Twig helpers so you can add lightweight JavaScript behaviour without a full front-end framework. Simplifies wiring Symfony assets to Stimulus.
This is an initial assessment for v0.2.0 of the package. The release adds a single method, setControllerNameToFormView(), which sets a controller data attribute on the rendered <form> tag. Treat the package as early-stage (0.x) and verify the exact attribute name in the rendered HTML before relying on it.
Start here:
src/ — find the form builder or form view class that renders the <form> tag. That is where setControllerNameToFormView() lives and where the data attribute is applied.data-controller or a package-specific key).Minimal first use case: render a form that a front-end controller (for example, a Stimulus/Hotwire controller) can hook into.
// In the controller or form-building layer that renders the form:
$form->setControllerNameToFormView('signup-form');
return view('signup', ['form' => $form]);
Inspect the rendered HTML to confirm the attribute appears on the <form> tag. If you are not using a JS controller framework, this method is still useful as a semantic hook for tests or for attaching behavior via data-* selectors.
Set the controller name at the form-building layer, not in the Blade view. The method belongs to the form object, so call it in the controller/action, form request, or dedicated form class before the view renders. This keeps the form definition testable and avoids scattering attribute logic across templates.
public function create()
{
$form = $this->formBuilder->make('signup');
$form->setControllerNameToFormView('signup-form');
return view('signup.create', compact('form'));
}
Use it as the front-end integration point for interactive forms. The most natural day-to-day use is attaching a Stimulus (or similar) controller to a form that needs client-side validation, auto-save, conditional fields, or submission state handling. The package now avoids hand-writing the data attribute in Blade.
Keep controller names stable and descriptive. Use names that match your JS controller identifiers (for example, signup-form, checkout-validation, search-filters). If multiple forms appear on one page, set a distinct controller name per form rather than reusing a generic one.
Assert the rendered attribute in tests. Since the feature is a rendered HTML attribute, cover it at the view/integration level:
$response = $this->get('/signup');
$response->assertSee('data-controller="signup-form"', false);
Adjust the assertion to the actual attribute key produced by the package.
Combine with existing form attributes deliberately. If your form builder already supports attributes, methods, or action configuration, set the controller name alongside those calls and confirm that later attribute rendering does not overwrite the data attribute.
data-controller, data-controller-name, or another key. Inspect the HTML before writing JS selectors or test assertions.assertSee(..., false), browser dev tools, or a quick dd($form) to confirm the form object state and the final tag output.composer.json and re-check rendered output after upgrades.How can I help you explore Laravel packages today?