liip/hyphenator-bundle
Symfony bundle that adds automatic hyphenation to templates via a Twig filter, wrapping the Org\Heigl\Hyphenator library. Configure locales, patterns, and quality settings inYAML, then let long words wrap cleanly in rendered HTML, emails, and PDF output.
Status check first: this bundle is archived and its last release was 2015-10-24. It was built for the Symfony 2/3 era. Use it to maintain a legacy app; for new work, prefer the underlying
org_heigl/hyphenatorlibrary directly or CSShyphens: autowith properlangattributes.
composer require liip/hyphenator-bundle — pin to a version that installs against your Symfony; on Symfony 4+ you may need to register the bundle manually.Liip\HyphenatorBundle\LiipHyphenatorBundle in AppKernel (or config/bundles.php).liip_hyphenator:
locale: de_DE
cache_dir: '%kernel.cache_dir%/hyphenator'
README.md — short, shows the service and config.DependencyInjection/Configuration.php — authoritative list of keys (locale, cache_dir, quality, left_min, right_min, word_min, filters/no-hyphenate patterns).Resources/config/services.xml — the actual service id (typically liip_hyphenator) and Twig extension wiring.$hyphenator = $this->get('liip_hyphenator'); // or inject it
echo $hyphenator->hyphenate('Donaudampfschifffahrtsgesellschaft');
// Donaudampfschifffahrtsgesellschaft (soft hyphens, U+00AD)
In Twig, the bundle's extension exposes a filter:
<h1>{{ 'Donaudampfschifffahrtsgesellschaft'|hyphenate }}</h1>
Why server-side hyphenation at all: CSS hyphens: auto depends on browser support and a correct lang attribute. Soft hyphens inserted server-side break consistently everywhere, including PDFs, emails, and older browsers.
services:
Org\Heigl\Hyphenator\Hyphenator: '@liip_hyphenator'
hyphenate($text, $request->getLocale())). Confirm the pattern set for that locale exists.overflow-wrap as a fallback.hyphens: auto.U+00AD), not -. It's invisible but present in strings: copy/paste, search, JSON APIs, and strlen all see it. Strip it (str_replace("\x{00AD}", '', $s)) at boundaries.cache_dir must be writable. The library parses TeX-style patterns and caches them; first use per locale is slow, and a read-only container filesystem will hurt. Clear the cache after upgrading the underlying library — the cache format can change.de_DE vs de, and locales without patterns may silently fall back or not hyphenate at all. Test with real compound words, not hello.word_min / left_min / right_min. Defaults can hyphenate too aggressively; standard typography is roughly word_min 6+, left_min/right_min 2–3.quality trades CPU for correctness. Benchmark on long lists; consider caching hyphenated output by hash for high-traffic pages.­ (needs |raw) or the literal U+00AD character. Check which, and confirm the extension is auto-registered on your Symfony version.bin/console debug:container liip_hyphenator (older Symfony: container:debug) to confirm wiring; call hyphenate() in a throwaway command and inspect with bin2hex() to verify U+00AD placement.How can I help you explore Laravel packages today?