@@ -25,14 +25,56 @@ Supports PHP 5.6 and up, so you can use it on older servers.
2525
2626Quick start
2727-----------
28- Just include phpSyllable in your project, set up the autoloader to the classes
29- directory and instantiate yourself a Syllable class.
28+
29+ Install phpSyllable via Composer
30+
31+ ```
32+ composer require vanderlee/syllable
33+ ```
34+
35+ or simply add phpSyllable to your project and set up the project's
36+ autoloader for phpSyllable's src/ directory.
37+
38+ Then instantiate a Syllable object and start hyphenation.
39+
40+ Minimal example:
3041
3142``` php
32- $syllable = new Syllable('en-us');
43+ $syllable = new \Vanderlee\Syllable\ Syllable('en-us');
3344echo $syllable->hyphenateText('Provide a plethora of paragraphs');
3445```
3546
47+ Extended example:
48+
49+ ``` php
50+ use Vanderlee\Syllable\Syllable;
51+ use Vanderlee\Syllable\Hyphen;
52+
53+ // Globally set the directory where Syllable can store cache files.
54+ Syllable::setCacheDir(__DIR__ . '/cache');
55+
56+ // Globally set the directory where the .tex files are stored.
57+ // By default, this is the languages/ folder of this package and
58+ // usually does not need to be adapted.
59+ Syllable::setLanguageDir(__DIR__ . '/languages');
60+
61+ // Create a new instance for the language.
62+ $syllable = new Syllable('en-us');
63+
64+ // Set the style of the hyphen. In this case it is the "-" character.
65+ // By default, it is the soft hyphen "­ ; ".
66+ $syllable->setHyphen(new Hyphen\Dash());
67+
68+ // Set the minimum word length required for hyphenation.
69+ // By default, all words are hyphenated.
70+ $syllable->setMinWordLength(5);
71+
72+ // Output hyphenated text.
73+ echo $syllable->hyphenateText('Provide your own paragraphs...');
74+ ```
75+
76+ See the [ demo.php] ( demo.php ) file for a working example.
77+
3678` Syllable ` class reference
3779--------------------------
3880The following is an incomplete list, containing only the most common methods.
@@ -162,35 +204,6 @@ Count the number of syllables in the text.
162204
163205Count the number of polysyllables in the text.
164206
165- Example
166- -------
167- See the [ demo.php] ( demo.php ) file for a working example.
168-
169- ``` php
170- // Setup the autoloader (if needed)
171- require_once dirname(__FILE__) . '/classes/autoloader.php';
172- use Vanderlee\Syllable\Syllable;
173-
174- // Create a new instance for the language
175- $syllable = new Syllable('en-us');
176-
177- // Set the directory where the .tex files are stored
178- $syllable->getSource()->setPath(__DIR__ . '/languages');
179-
180- // Set the directory where Syllable can store cache files
181- $syllable->getCache()->setPath(__DIR__ . '/cache');
182-
183- // Set the hyphen style. In this case, the ­ ; HTML entity
184- // for HTML (falls back to '-' for text)
185- $syllable->setHyphen(new Syllable_Hyphen_Soft);
186-
187- // Set the treshold (sensitivity)
188- $syllable->setTreshold(Syllable::TRESHOLD_MOST);
189-
190- // Output hyphenated text
191- echo $syllable->hyphenateText('Provide your own paragraphs...');
192- ```
193-
194207Development
195208-----------
196209
0 commit comments