symfony/ux-turbo
Symfony UX Turbo integrates Hotwire Turbo into Symfony apps, enabling faster navigation, Turbo Frames/Streams updates, and smoother UX with minimal custom JavaScript. Includes Stimulus integration and tools to progressively enhance pages and forms.
<twig:Turbo:Stream>, <twig:Turbo:Frame>) and functions (turbo_stream_from(), turbo_is_frame_request()), aligning with Symfony’s templating philosophy.data-turbo-* attributes to HTML elements). Ideal for teams with stronger PHP than JavaScript expertise.symfony/mercure-bundle (v0.4.1+), adding another moving part but enabling powerful use cases like live notifications.TurboStreamListenRendererInterface). Teams using older Symfony UX packages (e.g., symfony/ux-turbo-mercure) must migrate to mercure-bundle.type: module in package.json), which may require adjustments to existing asset pipelines or browser support considerations.data-turbo="false").Symfony Version Compatibility:
turbo_stream_listen()) in existing code?Frontend Strategy:
type: module) for Turbo’s JS, or can we use a CDN?Real-Time Requirements:
Performance:
Team Skills:
data-turbo-* attributes)?Fallbacks:
Long-Term Maintenance:
@Broadcast attribute).Assessment Phase:
Setup:
composer require symfony/ux-turbo symfony/mercure-bundle # if needed
symfony/ux-turbo in config/bundles.php:
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
Symfony\UX\MercureBundle\MercureBundle::class => ['all' => true],
assets/controllers.json to enable the mercure-turbo-stream controller (if using Mercure).Incremental Adoption:
<turbo-frame> tags.<turbo-frame id="user_profile">
{% include 'user/profile.html.twig' %}
</turbo-frame>
TurboStreamResponse:
use Symfony\UX\Turbo\TurboBundle;
public function updateProfile(Request $request): Response
{
// ... update logic
if (TurboBundle::STREAM_FORMAT === $request->getPreferredFormat()) {
return $this->render('user/_profile.stream.html.twig', ['user' => $user]);
}
return $this->render('user/profile.html.twig', ['user' => $user]);
}
data-turbo attributes to links/forms:
<a href="/posts/1" data-turbo="true">View Post</a>
<form data-turbo="true">...</form>
<turbo-mercure-stream-source src="{{ path('mercure') }}" topics="{{ mercureHubUrl }}topic/posts">
@Broadcast:
#[Broadcast]
class Post {}
Testing:
Accept: text/vnd.turbo-stream.html.data-turbo="false").symfony/mercure-bundle (v0.4.1+) for real-time features.symfony/ux-turbo-mercure to mercure-bundle (if applicable).symfony/ux-turbo and configure bundles.How can I help you explore Laravel packages today?