Download the PHP package bitandblack/hyphenizer-bundle without Composer
On this page you can find all versions of the php package bitandblack/hyphenizer-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bitandblack/hyphenizer-bundle
More information about bitandblack/hyphenizer-bundle
Files in bitandblack/hyphenizer-bundle
Package hyphenizer-bundle
Short Description Perfect hyphenation for your Website. This library integrates the Hyphenizer into your Symfony project.
License MIT
Homepage https://www.hyphenizer.com
Informations about the package hyphenizer-bundle
Bit&Black Hyphenizer Bundle
Perfect hyphenation for your Website. This library integrates the Hyphenizer into your Symfony project.
If you don't run your website with Symfony, you can integrate the Hyphenizer SDK for PHP by your own.
Please note: The Hyphenizer API requires you to have a valid API token.
Installation
This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/hyphenizer-bundle.
Usage
Basic setup and usage of the Bit&Black Hyphenizer Bundle
The Bit&Black Hyphenizer bundle offers a smooth way to extract and hyphenate long words automatically. It implements the Hyphenizer SDK for PHP and allows to update the extracted words.
To use this library in your project, wrap your texts with the AutoHyphenation class. This will add soft hyphens to all words, that are long enough to be hyphenated:
It's also possible to hyphenate using a Twig filter:
Inside, the class extracts all words having more than 12 characters, and searches for a previously defined hyphenation.
You can change this value when initialising the class.
The hyphenations themselves are stored inside a JSON file using a pipe, for example
whereas the pipe is getting replaced afterwards by the defined hyphenation character. This is a soft hyphen per default. You can change the hyphenation character when initialising the class.
The JSON file is getting stored under /hyphenation/words-hyphenated.json.
The list of extracted words will grow over time. You can add hyphenations by yourself, by modifying the JSON file, but it's also possibly to do this via script:
This is the manual approach. The approach that you’ll really enjoy is:
Using the Hyphenation API for automatic hyphenation
This library provides a command, to contact the Hyphenation API and ask for validated hyphenations:
The response will contain more information about every hyphenated word, for example a score and if the hyphenation has been approved.
The response will also be stored in the words-hyphenated.json file.
Extracting words manually
If you don't want to wait, until your hyphenation list contains all words from your project, you can manually scan your files and extract the words from there:
Using the hyphenations with JavaScript
If you want to use the hyphenations in JavaScript, you can use the Hyphenation library written in JavaScript to do that. In this case, you need to import your words-hyphenated.json before initialising the class:
Help
If you have any questions, feel free to contact us under [email protected].
Further information about Bit&Black can be found under www.bitandblack.com.
All versions of hyphenizer-bundle with dependencies
bitandblack/hyphenizer-sdk-php Version ^0
kiwa/hyphenizer Version ^1.0
nyholm/psr7 Version ^1.0
symfony/console Version ^7.0 || ^8.0
symfony/framework-bundle Version ^7.0 || ^8.0
symfony/http-client Version ^7.0 || ^8.0
twig/twig Version ^3.0