- What is timnarr/hyphenate used for?
- It is a server-side hyphenation package that inserts soft hyphens into words using TeX hyphenation patterns. In Laravel and plain PHP it helps improve line breaks, justification, and typography, and it also provides a Statamic modifier. Soft hyphens are invisible unless the browser or renderer breaks the word at that point.
- How do I install timnarr/hyphenate with Composer?
- Install it with Composer using composer require timnarr/hyphenate. Then use the package API in PHP or the Statamic modifier where applicable. Check the README and repository for any publishable configuration or framework-specific setup steps for your installation.
- Does timnarr/hyphenate work with Laravel?
- Yes, the package is described as server-side hyphenation for PHP and Laravel with a simple API that works in Laravel views. It is not limited to Laravel, so you can also use it in plain PHP. Review the package Composer constraints for the exact Laravel versions supported by your release.
- How do I use hyphenation in a Laravel Blade view?
- Use the package PHP API or helper in your Blade template to hyphenate a string before output. The exact method name should be taken from the README because the package is intended to work in Laravel views. Because it inserts soft hyphens, avoid applying it to raw HTML or attributes unless you have sanitized and tested the result.
- Which languages and hyphenation patterns are supported?
- The package uses TeX hyphenation patterns and supports multiple languages through pattern sets. The available languages depend on the bundled patterns and your configuration, so check the README for the exact list. You can configure the language or pattern set for the text being processed.
- Can I configure hyphenation behavior and patterns?
- Yes, the package provides configurable settings and multi-language pattern support. Configuration typically covers the language patterns and may include options for hyphenation behavior. See the package documentation for the exact configuration keys, defaults, and any publishable config file.
- Is timnarr/hyphenate safe to use in production?
- It is intended for server-side hyphenation and inserts soft hyphens into text, which are standard characters and safe in normal text output. You should still test with your content and escaping strategy, especially for user-generated or HTML content. For large volumes of text, consider caching or pre-processing hyphenated results.
- How can I test hyphenated output in PHPUnit or Laravel tests?
- Assert that the returned string contains the expected soft hyphen character at the expected positions, or compare against known fixture output. Keep tests focused on your configured language and pattern set. In Laravel, you can call the package API directly from a unit or feature test.
- What is the difference between soft hyphens and regular hyphens?
- A soft hyphen is an invisible optional break point; it only displays as a hyphen when the browser or renderer breaks the word there. A regular hyphen is a visible character that always appears. This package inserts soft hyphens to improve typography without changing visible text unless a break occurs.
- What are alternatives to timnarr/hyphenate for PHP hyphenation?
- Alternatives include other PHP hyphenation libraries based on TeX patterns, built-in CSS hyphens for browser-side hyphenation, and manual or CMS-specific solutions. This package is a good fit when you need server-side output, multi-language patterns, and integration with Laravel or Statamic. Compare language support, maintenance activity, and output format before switching.