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.
head content like meta tags to work properlyTurboFrame service methods and Twig functions turbo_is_frame_request()/turbo_frame_request_id() to detect Turbo Frame requests<turbo-mercure-stream-source> custom element, turbo_stream_from() Twig function and <twig:Turbo:Stream:From> Twig componentturbo_stream_listen() Twig function, use turbo_stream_from() or the <twig:Turbo:Stream:From> Twig component insteadSymfony\UX\Turbo\Twig\TurboStreamListenRendererInterface interface, use Symfony\UX\Turbo\StreamSourceRendererInterface insteadSymfony\UX\Turbo\Bridge\Mercure\TurboStreamListenRenderer class, use Symfony\UX\Turbo\Bridge\Mercure\MercureStreamSourceRenderer insteadSymfony\UX\Turbo\Bridge\Mercure\TopicSet classmercure-turbo-stream Stimulus controller, use the <turbo-mercure-stream-source> custom element insteadStimulusTwigExtension from WebpackEncoreBundle ^1.0, use StimulusBundle insteadTurboStreamListenRendererInterface::renderTurboStreamListen() $eventSourceOptions parameterMinimum PHP version is now 8.1
Add support for symfony/asset-mapper
Replace symfony/webpack-encore-bundle by symfony/stimulus-bundle in dependencies
Add assets/src to .gitattributes to exclude source TypeScript files from
installing.
TypeScript types are now included.
The symfony/ux-turbo-mercure package was abandoned and moved into this package.
If you were previously using symfony/ux-turbo-mercure, you can remove it
and only install mecure-bundle:
composer require symfony/mercure-bundle
composer remove symfony/ux-turbo-mercure
After upgrading this package to 2.6.1, you should have a new entry in
assets/controllers.json called mercure-turbo-stream. Change
enabled: false to enabled: true.
[BC BREAK] The assets/ directory was moved from Resources/assets/ to assets/. Make
sure the path in your package.json file is updated accordingly.
The directory structure of the bundle was updated to match modern best-practices.
Broadcast attribute can now be repeated, this is convenient to render several Turbo Streams Twig templates for the same changemeta tagsturbo_stream_listen<twig:Turbo:Stream> component<twig:Turbo:Frame> componentTurboStream and TurboStreamResponseturbo_stream_listenHelper/TurboStream::append() et al. methodsTurboStreamResponse<twig:Turbo:Stream:*> componentsBroadcast attribute now support expression language when prefixed with @=.use statement used during broadcast #1475ClassUtils class that's not used in newer versions of Doctrinetype: module"type: moduleTurboStreamResponse and AddTurboStreamFormatSubscriber have been removed, use native content negotiation instead:
use Symfony\UX\Turbo\TurboBundle;
class TaskController extends AbstractController
{
public function new(Request $request): Response
{
// ...
if (TurboBundle::STREAM_FORMAT === $request->getPreferredFormat()) {
$request->setRequestFormat(TurboBundle::STREAM_FORMAT);
$response = $this->render('task/success.stream.html.twig', ['task' => $task]);
} else {
$response = $this->render('task/success.html.twig', ['task' => $task]);
}
return $response->setVary('Accept');
}
}
stimulus version 2 was removed and support for [@hotwired](https://github.com/hotwired)/stimulus
version 3 was added. See the [@symfony/stimulus-bridge CHANGELOG](https://github.com/symfony/stimulus-bridge/blob/main/CHANGELOG.md#300)
for more details.[@hotwired](https://github.com/hotwired)/turbo version bumped to stable 7.0.symfony/ux-turbo and symfony/ux-turbo-mercure
were introduced.How can I help you explore Laravel packages today?