Download the PHP package loupe/matcher without Composer

On this page you can find all versions of the php package loupe/matcher. 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 matcher

Loupe Matcher

Loupe Matcher turns plain search queries and arbitrary text into precise, user-friendly matches: tokenize phrases and negations, normalize language-specific spelling variants, decompose compound words, calculate match spans, and format the result with highlighting, cropping, and truncation.

Installation

Quick Start

Here's a simple example of how to use Loupe Matcher to highlight search terms in a text document and crop around the highlights:

Core Components

Tokenizer

Purpose: Breaks text into searchable tokens (words, phrases, terms) for accurate matching.

The Tokenizer converts strings into TokenCollection objects, handling:

If you want to configure the way the Tokenizer handles locale specifics (such as decomposition or normalization), you can provide your own implementation of the LocaleConfigurationInterface or use any of the pre-built configurations shipped with this library. There are currently the following:

Checkout the separate docs on decomposition if you want to improve the existing locale configurations or add support for a new one!

FastSet dictionary cache

The packaged dictionaries are compressed. On their first use, FastSet creates optimized index files. By default those files are written next to the packaged dictionary, which is usually inside vendor/. Pass a writable cache directory when creating a preconfigured locale to store them elsewhere:

The locale is appended to the supplied directory, so German files in this example are stored in /var/cache/my-app/loupe-matcher/de. Locale-specific directories are created automatically. You can also pass the same value as the $fastSetCacheDirectory second argument to new English() or new German().

Matcher

Purpose: Finds which tokens in your text match the search query.

The Matcher compares tokenized text against search terms, with support for:

Formatter

Purpose: Combines matching and highlighting to create formatted output with context.

The Formatter orchestrates the entire process:

Match Prioritization

By default, cropping emits snippets around every match cluster and truncation cuts from the start. Enabling withEnableMatchPrioritization() will attempt to choose the most relevant window(s) for display. Windows are scored by distinct query terms hit, then total matches, then density.

Advanced Usage

Custom Tokenizer

Implement TokenizerInterface for specialized tokenization:

Pre-highlighted Text Cropping

When you already have highlighted text that needs cropping:

Using Pre-calculated Matches

When you already have a TokenCollection of matches (e.g., from a previous search operation or external source), you can format text directly without re-calculating matches. This approach is useful when your search engine already provides match information or you want to cache match results for performance.


All versions of matcher with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-intl Version *
ext-mbstring Version *
toflar/fast-set Version ^1.0
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 loupe/matcher contains the following files

Loading the files please wait ...