org_heigl/hyphenator
org_heigl/hyphenator is a PHP library for automatic hyphenation using TeX patterns. It supports multiple languages, preserves HTML markup, and improves typography in web pages, emails, PDFs, and generated documents.
What it is: org_heigl/hyphenator is a pure-PHP implementation of Liang's TeX hyphenation algorithm (the same algorithm behind hyph-utf8 patterns used by LaTeX, InDesign, and browsers). It is a language/text-processing library, not a Laravel package — there is no service provider, facade, config file, or published assets. Value is entirely in correctness of hyphenation for justified or narrow-column text.
Architecture fit:
­ insertion.Hyphenator with pluggable tokenizers (whitespace, non-word, regex) and filters (simple, array, text). That composability maps well to a domain service such as App\Support\Typography\HyphenationService, keeping the vendor API out of controllers and Blade.Integration feasibility:
composer require org_heigl/hyphenator — trivial. No native extensions, no external services, MIT license, no telemetry.hyph-utf8 pattern corpus rather than ad-hoc .tex files — potentially removing the bespoke pattern-sourcing burden. And "apply single-letter hyphenation patterns" (PR #69) is a correctness fix in exactly the quality-sensitive area flagged previously (short syllables, German compounds, proper nouns). Both need confirmation against the actual code before scoping, but they point the right direction.v3.1.0 → v3.2.0). Target version confirmation is still required, but the ambiguity is now about the 3.x PHP matrix, not about which major to use.Technical risk:
hyph-utf8 patterns, note that upstream pattern files carry per-language licenses (LPPL, GPL, MIT, BSD variants). MIT on the PHP code does not automatically cover the pattern data. This is a new, concrete legal/compliance task — verify the license of each locale we intend to ship before distributing..tex pattern sets are multi-megabyte and parsed at runtime. If v3.2.0's hyph-utf8 support bundles more locales by default, the naive per-request memory profile gets worse, not better. Loaded-locale discipline becomes more important, not less.eval, no unserialize. The only injection vector is a user-influenced locale or pattern path — enforce a strict allow-list and never interpolate request input into a filesystem path. The v3.2.0 supply-chain work reduces build-time risk; runtime risk is unchanged.Key questions for the maintainer/team:
de, nl, sv, en)?Stack fit: Framework-agnostic library; Laravel fit is entirely up to our adapter. Recommended shape:
config/hyphenation.php -> enabled locales, leftMin/rightMin, pattern path
app/Providers/HyphenationServiceProvider.php
app/Support/Typography/HyphenationService.php (wraps Hyphenator)
app/Support/Typography/HyphenationManager.php (per-locale memoization)
Blade directive: @hyphenate($text, 'de_DE')
Bind HyphenationService as a singleton so pattern parsing happens once per worker. Expose a hyphenate(string $text, string $locale, string $mode): string method returning either soft-hyphen (­) or <wbr> output, with the mode a config concern rather than a caller concern.
Migration path:
v3.2.0 pinned, hyphenate a German and an English corpus, diff against a known-good reference (browser hyphens: auto, or LaTeX output). Explicitly test single-letter-break cases, since that behavior changed in this release.Compatibility:
composer.json — recommend 3.2.0 specifically. The release cadence is low but the 3.x line is now demonstrably active; still avoid ^ until a second 3.x patch confirms stability.de, nl, ru).symfony/string or intl usage — ideally benchmark against Symfony\Component\String\UnicodeString + a locale-aware alternative before committing, since that avoids a new dependency entirely.Hyphenator instance is shared across requests — re-verify after the v3.2.0 pattern refactor, since new pattern-loading paths are the most likely place for lazy-initialized mutable state to appear.Sequencing: correctness spike → license check → adapter + tests → pilot on a non-customer-facing render → feature-flagged rollout. Do not sequence it before the rendering problem is confirmed; this is a solution that should follow a diagnosed typography defect, not lead one.
Maintenance: Low absolute maintenance cost, and slightly lower than previously judged. Upstream now has PR-gated CI and a hardened Actions posture, so regressions are more likely to be caught before they reach us, and an external contributor has demonstrated the patch path is open. Budget roughly 2–4 hours per quarter to review upstream activity, plus a fork contingency. A "quiet fork" remains credible — document that decision now so it is not a crisis later. Add one recurring task: re-check pattern-file licenses on each minor bump, since the hyph-utf8 integration may pull in new locale data.
Support: No vendor, no SLA, no commercial backing. Internal support burden is the adapter plus the pattern data. Add runbook notes covering: which locales are enabled, where pattern files live, how to add a locale, and what happens when a locale is unsupported. Most incidents will be "text rendered without breaks" rather than exceptions — silent quality degradation, which is harder to detect than a crash. The v3.2.0 single-letter fix is a reminder that correctness can shift between versions; golden-file tests are the only reliable way to notice.
Scaling:
cache()->remember() keyed on sha1(locale . text).Failure modes:
| Failure | Symptom | Detection | Mitigation |
|---|---|---|---|
| Missing/corrupt pattern file | Text unbroken, or exception on load | Golden-file tests; alert on exception | Integrity check on published pattern dir; fall back to pass-through |
| Unsupported locale | Silent no-op | Locale coverage report | Allow-list with explicit fallback to no hyphenation |
| Memory ceiling | Worker OOM under Octane | Memory profiling in CI/staging | Locale cap + lazy load; re-baseline after v3.2.0 |
| Path traversal via locale | File read outside pattern dir | Code review | Hard allow-list, no user input in paths |
| Pattern data license breach | Redistribution of incompatible locale data | License review at upgrade | Per-locale license inventory; exclude or replace offending locales |
| PHP upgrade breakage | Fatal on 8.x | CI matrix | Fork and patch; small surface |
| Over-hyphenation | Ugly output, broken words | Visual QA + fixture tests | Tune leftMin/rightMin; per-locale overrides; add single-letter fixture cases from v3.2.0 |
Ramp-up:
­ vs <wbr> vs precomputed) and on which locales are in scope, since each added locale is a maintenance and memory commitment.overflow-wrap/hyphens: auto may close it with zero dependencies. v3.2.0 makes the package a stronger candidate than before, but it does not make it a solution to an undiagnosed problem.How can I help you explore Laravel packages today?