Without the framework
The PHP half depends on Symfony components only, not on symfony/framework-bundle: it works in projects that wire an
event dispatcher by hand. Skip SilarhiTurboBundle and instantiate the classes:
use Silarhi\TurboBundle\EventListener\TurboFrameListener;use Silarhi\TurboBundle\TurboManager;use Silarhi\TurboBundle\Twig\TurboExtension;
$turboManager = new TurboManager($requestStack);$dispatcher->addSubscriber(new TurboFrameListener($turboManager));
// Optional: the turbo_frame Twig filter (requires twig/twig).// The second argument is the base template the filter falls back to (default: 'base-frame.html.twig').$twig->addExtension(new TurboExtension($turboManager, 'base-frame.html.twig'));TurboFrameListener also follows DELETE redirects on Turbo requests by default; pass
new TurboFrameListener($turboManager, followDeleteRedirects: false) to disable that.
Requirements
Section titled “Requirements”$requestStackmust be theRequestStackyourHttpKernelpushes requests on:TurboManagerreads the headers of its current request, and answers as for a plain, non-Turbo request when there is none.$dispatchermust be the event dispatcher of thatHttpKernel: the listener subscribes tokernel.response.- Outside a request (a console command, a message handler, an email), the
turbo_framefilter returns the template unchanged.
See the PHP API reference for every public method.
