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 (config, dependency-injection, event-dispatcher, http-foundation, http-kernel) | 6.4 / 7.x / 8.x |
@hotwired/turbo (peer dependency of @silarhi/turbo) |
7.1+ / 8.x |
visitOnFrameMissing needs Turbo 7.2+, and morph renders exist since Turbo 8. Following DELETE redirects outside a
frame also needs Turbo 8: the bundle recognizes these requests by the X-Turbo-Request-Id header, which Turbo 7 does
not send (DELETE redirects).
Optional dependencies
Section titled “Optional dependencies”| Package | Required for |
|---|---|
symfony/framework-bundle |
Registering SilarhiTurboBundle for zero-config service wiring |
twig/twig |
The turbo_frame Twig filter |
JavaScript half
Section titled “JavaScript half”pnpm add @silarhi/turboWith 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 Symfony components only, so a project that wires its event dispatcher by hand can instantiate them itself: see Without the framework.
