Skip to content

Commit e6b723a

Browse files
authored
Merge pull request #67 from alexander-nitsche/task-update-readme-installation-section
Update the "Quick Start" section in README.md.
2 parents 47936d9 + 9f350c1 commit e6b723a

4 files changed

Lines changed: 247 additions & 235 deletions

File tree

README.md

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,56 @@ Supports PHP 5.6 and up, so you can use it on older servers.
2525

2626
Quick 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');
3344
echo $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
--------------------------
3880
The following is an incomplete list, containing only the most common methods.
@@ -162,35 +204,6 @@ Count the number of syllables in the text.
162204

163205
Count 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-
194207
Development
195208
-----------
196209

build/classes/DocumentationManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function updateReadme()
149149

150150
$readme = file_get_contents($this->readmeFile);
151151
$apiDocumentationStart = strpos($readme, '###', strpos($readme, "`Syllable` class reference\n--------------------------"));
152-
$apiDocumentationEnd = strpos($readme, "Example\n-------", $apiDocumentationStart);
152+
$apiDocumentationEnd = strpos($readme, "Development\n-----------", $apiDocumentationStart);
153153
$apiDocumentationLength = $apiDocumentationEnd - $apiDocumentationStart;
154154
$apiDocumentationOld = '';
155155
$readmeState = 0;
@@ -164,7 +164,7 @@ protected function updateReadme()
164164

165165
if ($readmeState < 1) {
166166
if (!($readmeState & 1)) {
167-
$errors[] = 'Missing headlines "`Syllable` class reference" and "Example" to locate API documentation.';
167+
$errors[] = 'Missing headlines "`Syllable` class reference" and "Development" to locate API documentation.';
168168
}
169169
if (isset($errors)) {
170170
throw new Exception(sprintf(

0 commit comments

Comments
 (0)