chuoke/keyword-linkify

Replace keywords in articles with links

Maintainers

👁 chuoke

Package info

github.com/chuoke/keyword-linkify

pkg:composer/chuoke/keyword-linkify

Fund package maintenance!

chuoke

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

1.0.1 2022-10-24 12:05 UTC

Requires

  • php: ^8

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 391dadb78028dc3393e4f2067f3aa78bf3f613ba

  • chuoke <chuokechungyoung.woop@gmail.com>

chuokekeyword-linkifyå…ģé”ŪčŊæ›ŋæĒäļšé“ūæŽĨ

This package is auto-updated.

Last update: 2026-06-22 11:53:21 UTC


README

👁 Latest Version on Packagist
👁 Tests
👁 Total Downloads

Installation

You can install the package via composer:

composer require chuoke/keyword-linkify

Usage

$text = '<img class="hero-logo" src="/images/logos/php-logo-white.svg" alt="php" width="240" height="120">
 <p class="hero-text">A <strong>popular general-purpose scripting language</strong> that is especially suited to web development.<br>Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.</p>';

$keywords = [
 [
 'keyword' => 'php',
 'url' => 'https://www.php.net/',
 ],
];

$keywordLinkify = new Chuoke\KeywordLinkify();
echo $keywordLinkify->replace($text, $keywords);

The result:

<img class="hero-logo" src="/images/logos/php-logo-white.svg" alt="php" width="240" height="120"><p class="hero-text">A <strong>popular general-purpose scripting language</strong> that is especially suited to web development.<br>Fast, flexible and pragmatic, <a target="blank" href="https://www.php.net/" title="PHP">PHP</a> powers everything from your blog to the most popular websites in the world.</p>

👁 Image

As you can see, it won't replace attribute text.

More example see tests.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.