PHPackages                             richarddobron/highlight-search-term - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. richarddobron/highlight-search-term

ActiveLibrary[Search &amp; Filtering](/categories/search)

richarddobron/highlight-search-term
===================================

Lightweight PHP library designed to highlight search terms in text.

0.1.0(1y ago)03.9kMITPHPPHP ^8.1CI passing

Since Apr 14Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/richardDobron/highlight-search-term)[ Packagist](https://packagist.org/packages/richarddobron/highlight-search-term)[ RSS](/packages/richarddobron-highlight-search-term/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

 [![HIGHLIGHT your search](./logo/logo.svg)](./logo/logo.svg)Lightweight PHP library designed to highlight search terms in text.

📖 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- [Composer](https://getcomposer.org) is required for installation
- PHP Extensions: `ext-intl`, `ext-mbstring`

📦 Installation
--------------

[](#-installation)

Install the library using Composer:

```
$ composer require richarddobron/highlight-search-term
```

⚡️ Quick Start
--------------

[](#️-quick-start)

Here’s how to use the library to highlight search terms:

```
use dobron\Highlight\Config\TypoTolerance;
use dobron\Highlight\Configuration;
use dobron\Highlight\HighlightFactory;

$configuration = Configuration::create()
    ->withLanguages(['en'])
    ->withMaxQueryTokens(10)
    ->withTypoTolerance(TypoTolerance::create()->withFirstCharTypoCountsDouble(false)); // can be further fine-tuned but is enabled by default

$highlightResult = (new HighlightFactory())
    ->create(__DIR__ . '/cache', $configuration)
    ->highlight('world', 'Hello world!');

echo $highlightResult->getHighlightedText(); // Hello world!
```

⚙️ Configuration Options
------------------------

[](#️-configuration-options)

You can customize the library with the following methods:

MethodDescriptionDefault`withLanguages(array $languages)`Sets the languages to be used for tokenization.`[]``withMaxQueryTokens(int $maxQueryTokens)`Sets the maximum number of tokens to be used for tokenization.`10``withStopWords(array $stopWords)`Sets the stop words to be used for tokenization.`[]``withSynonyms(array $synonyms)`Sets the synonyms to be used for tokenization.`[]``withMinTokenLengthForPrefixSearch(int $minTokenLength)`Sets the minimum token length for prefix search.`3``withTypoTolerance(TypoTolerance $typoTolerance)`Sets the typo tolerance configuration.`TypoTolerance::create()``withLanguageDetection(bool $languageDetection)`Enables or disables language detection.`false`📅 Change Log
------------

[](#-change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🧪 Testing
---------

[](#-testing)

```
$ composer tests
```

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

🙋 Credits
---------

[](#-credits)

- [Richard Dobroň](https://github.com/richardDobron)
- [Yanick Witschi](https://github.com/loupe-php/loupe)

⚖️ License
----------

[](#️-license)

This repository is MIT licensed, as found in the [LICENSE](LICENSE) file.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance63

Regular maintenance activity

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ce70053083f807f4416f0bafe680691b66cd14f3c1bdf7b3df51b6f5b5cfdea?d=identicon)[dobron](/maintainers/dobron)

---

Top Contributors

[![richardDobron](https://avatars.githubusercontent.com/u/33115305?v=4)](https://github.com/richardDobron "richardDobron (3 commits)")

---

Tags

highlighthighlightingresultssearch

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/richarddobron-highlight-search-term/health.svg)

```
[![Health](https://phpackages.com/badges/richarddobron-highlight-search-term/health.svg)](https://phpackages.com/packages/richarddobron-highlight-search-term)
```

###  Alternatives

[loupe/loupe

A full text search engine with tokenization, stemming, typo tolerance, filters and geo support based on only PHP and SQLite

497185.2k14](/packages/loupe-loupe)[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15224.3M65](/packages/opensearch-project-opensearch-php)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)[handcraftedinthealps/zendsearch

a general purpose text search engine written entirely in PHP 5

39921.0k35](/packages/handcraftedinthealps-zendsearch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
