PHPackages                             yarri/keywords-highlighter - 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. yarri/keywords-highlighter

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

yarri/keywords-highlighter
==========================

Highlights keywords (typically a search query) in a HTML string

v0.1.5(4y ago)023.6k↓72%1MITPHPPHP &gt;=5.4.0

Since Nov 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/yarri/KeywordsHighlighter)[ Packagist](https://packagist.org/packages/yarri/keywords-highlighter)[ Docs](https://github.com/yarri/KeywordsHighlighter)[ RSS](/packages/yarri-keywords-highlighter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (1)

Keywords Highlighter
====================

[](#keywords-highlighter)

[![Build Status](https://camo.githubusercontent.com/29cc86e20e3cdcabd5abf1e757cbca6492dac3e113565bae20fa23e615e7d175/68747470733a2f2f6170702e7472617669732d63692e636f6d2f79617272692f4b6579776f726473486967686c6967687465722e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/yarri/KeywordsHighlighter)[![Downloads](https://camo.githubusercontent.com/ff4f3b81c8203d4a58c24c71d8eee5be47d2de36666346cb92ef46b60eec5720/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f79617272692f6b6579776f7264732d686967686c6967687465722e737667)](https://packagist.org/packages/yarri/keywords-highlighter)

Highlights keywords (typically a search query) in a HTML string.

Basic usage
-----------

[](#basic-usage)

```
$html_text = '
  The truth about pizza and beer

    Beer and pizza.
    It might be one of the most obvious food pairings on the planet...

';

$highlighter = new \Yarri\KeywordsHighlighter();

echo $highlighter->highlight($html_text,"pizza beer");

//  The truth about pizza and beer
//
//
//    Beer and pizza.
//    It might be one of the most obvious food pairings on the planet...
//

```

The default tag for highlighting can be overwritten in options of the constructor.

```
$highlighter = new \Yarri\KeywordsHighlighter([
  "opening_tag" => '',
  "closing_tag" => '',
]);

echo $highlighter->highlight($html_text,"pizza beer");

//  The truth about pizza and beer
//
//
//    Beer and pizza.
//    It might be one of the most obvious food pairings on the planet...
//

```

KeywordsHighlighter doesn't highlight something inside a html tag.

```
$html_text = '
  The truth about the H1 element
';

$highlighter = new \Yarri\KeywordsHighlighter();

echo $highlighter->highlight($html_text,"h1");

// The truth about the H1 element

```

Installation
------------

[](#installation)

```
composer require yarri/keywords-highlighter

```

Testing
-------

[](#testing)

```
composer update --dev
cd test
../vendor/bin/run_unit_tests

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Every ~72 days

Recently: every ~89 days

Total

6

Last Release

1639d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6304dffbd91d7a978f98632b0e4e30d662dcdb691daadb1388a58984e98faf5c?d=identicon)[yarri](/maintainers/yarri)

---

Top Contributors

[![yarri](https://avatars.githubusercontent.com/u/974278?v=4)](https://github.com/yarri "yarri (39 commits)")

---

Tags

searchhtmlhighlightkeywordkeywordshighlighting

### Embed Badge

![Health badge](/badges/yarri-keywords-highlighter/health.svg)

```
[![Health](https://phpackages.com/badges/yarri-keywords-highlighter/health.svg)](https://phpackages.com/packages/yarri-keywords-highlighter)
```

###  Alternatives

[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k178.3M943](/packages/elasticsearch-elasticsearch)[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[solarium/solarium

PHP Solr client

93532.7M98](/packages/solarium-solarium)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[hollodotme/treemdown

A PHP class for browsing markdown files with HTML rendering, syntax highlighting and search

1440.9k3](/packages/hollodotme-treemdown)

PHPackages © 2026

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