Download the PHP package vanderlee/syllable without Composer

On this page you can find all versions of the php package vanderlee/syllable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package syllable

Syllable

Version 1.7

Tests

Copyright © 2011-2023 Martijn van der Lee. MIT Open Source license applies.

Introduction

PHP Syllable splitting and hyphenation. or rather... PHP Syl-la-ble split-ting and hy-phen-ation.

Based on the work by Frank M. Liang (http://www.tug.org/docs/liang/) and the many volunteers in the TeX community.

Many languages supported. i.e. english (us/uk), spanish, german, french, dutch, italian, romanian, russian, etc. 76 languages in total.

Language sources: http://tug.org/tex-hyphen/#languages

Supports PHP 5.6 and up, so you can use it on older servers.

Installation

Install phpSyllable via Composer

or simply add phpSyllable to your project and set up the project's autoloader for phpSyllable's src/ directory.

Usage

Instantiate a Syllable object and start hyphenation.

Minimal example:

Extended example:

See the demo.php file for a working example.

Syllable API reference

The following describes the API of the main Syllable class. In most cases, you will not use any other functions. Browse the code under src/ for all available functions.

public __construct($language = 'en-us', string|Hyphen $hyphen = null)

Create a new Syllable class, with defaults.

public static setCacheDir(string $dir)

Set the directory where compiled language files may be stored. Default to the cache subdirectory of the current directory.

public static setEncoding(string|null $encoding = null)

Set the character encoding to use. Specify null encoding to not apply any encoding at all.

public static setLanguageDir(string $dir)

Set the directory where language source files can be found. Default to the languages subdirectory of the current directory.

public setLanguage(string $language)

Set the language whose rules will be used for hyphenation.

public setHyphen(mixed $hyphen)

Set the hyphen text or object to use as a hyphen marker.

public getHyphen(): Hyphen

Get the current hyphen object.

public setCache(Cache $cache = null)

public getCache(): Cache

public setSource($source)

public getSource(): Source

public setMinWordLength(int $length = 0)

Words need to contain at least this many character to be hyphenated.

public getMinWordLength(): int

public setLibxmlOptions(int $libxmlOptions)

Options to use for HTML parsing by libxml. See: https://www.php.net/manual/de/libxml.constants.php.

public excludeAll()

Exclude all elements.

public excludeElement(string|string[] $elements)

Add one or more elements to exclude from HTML.

public excludeAttribute(string|string[] $attributes, $value = null)

Add one or more elements with attributes to exclude from HTML.

public excludeXpath(string|string[] $queries)

Add one or more xpath queries to exclude from HTML.

public includeElement(string|string[] $elements)

Add one or more elements to include from HTML.

public includeAttribute(string|string[] $attributes, $value = null)

Add one or more elements with attributes to include from HTML.

public includeXpath(string|string[] $queries)

Add one or more xpath queries to include from HTML.

public splitWord(string $word): array

Split a single word on where the hyphenation would go. Punctuation is not supported, only simple words. For parsing whole sentences please use Syllable::splitWords() or Syllable::splitText().

public splitWords(string $text): array

Split a text into an array of punctuation marks and words, splitting each word on where the hyphenation would go.

public splitText(string $text): array

Split a text on where the hyphenation would go.

public hyphenateWord(string $word): string

Hyphenate a single word.

public hyphenateText(string $text): string

Hyphenate all words in the plain text.

public hyphenateHtml(string $html): string

Hyphenate all readable text in the HTML, excluding HTML tags and attributes. Deprecated: Use the UTF-8 capable hyphenateHtmlText() instead. This method is kept only for backward compatibility and will be removed in the next major version 2.0.

public hyphenateHtmlText(string $html): string

Hyphenate all readable text in the HTML, excluding HTML tags and attributes. This method is UTF-8 capable and should be preferred over hyphenateHtml().

public histogramText(string $text): array

Count the number of syllables in the text and return a map with syllable count as key and number of words for that syllable count as the value.

public countWordsText(string $text): int

Count the number of words in the text.

public countSyllablesText(string $text): int

Count the number of syllables in the text.

public countPolysyllablesText(string $text): int

Count the number of polysyllables in the text.

Development

Update language files

Run

to fetch the latest language files remotely and optionally use environment variables to customize the update process:

CONFIGURATION_FILE

Specify the absolute path of the configuration file where the language files to be downloaded are defined. The configuration file has the following format:

where the attributes are self-explanatory and _comment and disabled are optional. See for example build/update-language-files.json. Default: The build/update-language-files.json file of this package.

MAX_REDIRECTS

Specify the maximum number of URL redirects allowed when retrieving a language file. Default: 1.

WITH_COMMIT

Create (1) or skip (0) a Git commit from the updated language files. Default: 0.

LOG_LEVEL

Set the verbosity of the script to verbose (6), warnings and errors (4), errors only (3) or silent (0). Default: 6.

For example use

to silently run the script without outputting any logging.

Update API documentation

Run

to update the API documentation in this README.md. This should be done when the Syllable class has been modified. Optionally, you can use environment variables to modify the documentation update process:

WITH_COMMIT

Create (1) or skip (0) a Git commit from the adapted files. Default: 0.

LOG_LEVEL

Set the verbosity of the script to verbose (6), warnings and errors (4), errors only (3) or silent (0). Default: 6.

Create release

Run

to create a local release of the project by adding a changelog to this README.md. Optionally, you can use environment variables to modify the release process:

RELEASE_TYPE

Set the release type to major (0), minor (1) or patch (2) release. Default: 2.

WITH_COMMIT

Create (1) or skip (0) a Git commit from the adapted files and apply the release tag. Default: 0.

LOG_LEVEL

Set the verbosity of the script to verbose (6), warnings and errors (4), errors only (3) or silent (0). Default: 6.

Tests

Run

to execute the tests.

Changes

1.7

1.6

1.5.5

1.5.4

1.5.3

1.5.2

1.5.1

1.5

1.4.6

1.4.5

1.4.4

1.4.3

1.4.2

1.4.1

1.4

1.3.1

1.3

1.2


All versions of syllable with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
ext-json Version *
ext-libxml Version *
ext-mbstring Version *
ext-dom Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vanderlee/syllable contains the following files

Loading the files please wait ....