- How do I install org_heigl/hyphenator in a Laravel application?
- Install it with composer require org_heigl/hyphenator. It is a framework-agnostic, pure-PHP library, so Composer is the only setup step. There is no auto-discovery, service provider, facade, config file, or published asset, so all Laravel wiring is manual. Plan a small adapter service plus an optional service provider if you want container bindings.
- Is org_heigl/hyphenator a Laravel package with a service provider?
- No. It is a standalone text-processing library that implements Liang's TeX hyphenation algorithm, not a Laravel package. You get a Hyphenator class with pluggable tokenizers and filters, and you decide how to bind it. The recommended pattern is a thin App\Support\Typography\HyphenationService wrapper registered through your own provider so vendor APIs stay out of controllers and Blade templates.
- Which PHP and Laravel versions does org_heigl/hyphenator support?
- Laravel version support is effectively whatever your app runs, because the library has no framework coupling. PHP version compatibility for the 2.x line is not clearly documented and must be verified against your target runtime such as PHP 8.2, 8.3, or 8.4, especially around constructor syntax and mbstring versus strlen/substr usage. Run a quick smoke test on your actual runtime before committing. Also confirm the published release tags on Packagist, since the listed release metadata looks anomalous.
- How do I insert soft hyphens into words with the hyphenator?
- Instantiate the Hyphenator with the hyphenation character you want, typically the soft hyphen entity or the UTF-8 soft hyphen character, then run text through it. Tokenizers split input into words and filters let you skip short words, markup, or specific terms. Because soft hyphens are invisible until a line break occurs, this is safe for justified typography and for HTML rendered to PDF.
- Does org_heigl/hyphenator work with DomPDF, mPDF, or wkhtmltopdf invoices?
- Yes, this is one of the strongest use cases. Generate your HTML with soft hyphen characters inside long words, then hand it to DomPDF, mPDF, or wkhtmltopdf so the renderer can break lines more evenly in narrow columns. This improves justified text and reduces ugly gaps in invoices, reports, newsletters, and print-ready exports. It offers no benefit for JSON APIs, search indexing, or database storage, so do not add it to those paths.
- How do I handle multiple languages and TeX pattern files?
- Each locale needs its own TeX pattern set, and those sets are multi-megabyte files parsed at runtime. Point the library at a configurable pattern directory rather than a hardcoded path, and expose enabled locales in config/hyphenation.php. Decide explicitly what happens for unsupported locales: silently skip hyphenation or throw. For German, Dutch, or Swedish compound words, validate output per locale because incorrect breaks are visible quality defects.
- What is the performance and memory cost of hyphenation in a Laravel request?
- Pattern files are large and parsed at runtime, so instantiating a hyphenator per request or per word will show up in memory and CPU profiles. Bind it as a singleton or memoize per locale in a manager class, and consider precomputing hyphenated strings for static content instead of doing it at render time. Measure the footprint for your largest locale before enabling it broadly. If hyphenation only matters at render time, keep it out of hot request paths.
- Is org_heigl/hyphenator safe to use with user input or user-selected locales?
- The security surface is small: no network calls, no eval, and no unserialize. The realistic injection vector is a user-influenced locale or pattern file path, so enforce a strict allow-list of supported locales and never interpolate request input into a filesystem path. Validate locale codes against your config before resolving pattern files. Keep the library behind your own service so this validation happens in one place.
- How should I test hyphenation output in my Laravel app?
- You do not inherit a test suite, so you own correctness. Write golden-file tests per locale using representative words, proper nouns, and compound terms, and assert exact output including soft hyphen placement. Add feature tests around your HyphenationService and the Blade directive or helper that exposes it. This is the only reliable way to catch regressions when you upgrade the library or swap pattern files.
- Is org_heigl/hyphenator well maintained, and what are the alternatives?
- Adoption signal is weak: roughly 54 GitHub stars and zero Packagist dependents, a single maintainer, and low activity, so expect no community corpus for edge cases. The mitigating factor is that it is MIT licensed, pure PHP, and built on hyph-utf8 patterns, so forking or patching in-house is cheap. Alternatives include other PHP TeX hyphenation ports or handling breaks in the renderer itself, but few give you the same pattern quality. Verify the release history before relying on it in production.