Installation
The repository ships two packages, released from the same git tag. Install one, the other, or both.
| Package | Registry | What it does |
|---|---|---|
@silarhi/turbo |
npm | TurboHandler: runs your mount/unmount callbacks across every Turbo render, follows redirects. |
silarhi/turbo-bundle |
Packagist | Frame-redirect following and the turbo_frame Twig filter. |
Requirements
Section titled “Requirements”| Dependency | Version |
|---|---|
| PHP | 8.2+ |
| Symfony components (event-dispatcher, http-foundation, http-kernel) | 6.4 / 7.x / 8.x |
@hotwired/turbo (peer dependency of @silarhi/turbo) |
7.2+ / 8.x |
Morph renders, and so morphMutations, exist since Turbo 8. Turbo 7.1 lacks the
events the handler relies on to unmount a frame and to mount what a stream inserts (turbo:before-frame-render, the
render hook of turbo:before-stream-render), added in 7.2.
Optional dependencies
Section titled “Optional dependencies”| Package | Required for |
|---|---|
symfony/framework-bundle |
Registering SilarhiTurboBundle for zero-config service wiring |
twig/twig (3.8+) |
The Twig filters, functions and Turbo Stream renderer |
symfony/ux-twig-component |
The optional Turbo:Stream component (2.20+ or 3.x) |
symfony/config and symfony/dependency-injection are not installed with the package: only SilarhiTurboBundle
uses them, and a Symfony application already has them through symfony/framework-bundle.
JavaScript half
Section titled “JavaScript half”pnpm add @silarhi/turboIn a Symfony application with Flex and a package.json, skip this
step. As for the symfony/ux-* packages, composer require silarhi/turbo-bundle links the JS half from vendor/:
{ "devDependencies": { "@silarhi/turbo-bundle": "file:vendor/silarhi/turbo-bundle/assets" }}Run pnpm install and import from @silarhi/turbo-bundle instead of @silarhi/turbo: it is the same code, at the
version of your composer.lock. Composer has to run before the JS install, also in your CI.
With AssetMapper, add it to the import map instead:
php bin/console importmap:require @silarhi/turbo@hotwired/turbo is a peer dependency: a Turbo application already has it. The package does not import it, so the
import map gets a single entry. The package is an ES module with its TypeScript declarations. Continue with TurboHandler.
PHP half
Section titled “PHP half”composer require silarhi/turbo-bundleFull Symfony application
Section titled “Full Symfony application”Register the optional bundle for zero-config service wiring:
return [ // ... Silarhi\TurboBundle\SilarhiTurboBundle::class => ['all' => true],];TurboManager and TurboFrameListener are now registered (the listener is tagged kernel.event_subscriber
automatically), plus the turbo_frame Twig filter when Twig is installed. Every option has a default: see the
configuration reference to change them.
Without the framework
Section titled “Without the framework”The bundle class is optional. The services depend on HttpFoundation, HttpKernel and EventDispatcher only, not on the dependency injection container, so a project that wires its event dispatcher by hand can instantiate them itself: see Without the framework.
