PHPackages                             jedkirby/tweet-entity-linker - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jedkirby/tweet-entity-linker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jedkirby/tweet-entity-linker
============================

Convert Twitter API Tweet entities such as URLs, Hashtags and User Mentions into their respective HTML entities.

1.3.0(3y ago)102.7k↓100%1MITPHPPHP &gt;=5.6.4

Since Jan 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jedkirby/tweet-entity-linker)[ Packagist](https://packagist.org/packages/jedkirby/tweet-entity-linker)[ Docs](https://jedkirby.com)[ RSS](/packages/jedkirby-tweet-entity-linker/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (13)Used By (0)

Tweet Entity Linker
-------------------

[](#tweet-entity-linker)

[![Author](https://camo.githubusercontent.com/9c59e3b7cef70e55f38bf516bbdbfdd2a7888118928a81e530a0d1825e541935/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406a65646b697262792d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/jedkirby)[![Build Status](https://camo.githubusercontent.com/e9af88980576129f23583e75c6bae766eec139c2b1ff07f47f9704e6e6e7c6b4/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a65646b697262792f74776565742d656e746974792d6c696e6b65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/jedkirby/tweet-entity-linker)[![Test Coverage](https://camo.githubusercontent.com/518287d3ba4f2642d84ba09e09710cacc0eef0d7a3bb3ee4b43673d0798caf9e/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6a65646b697262792f74776565742d656e746974792d6c696e6b65722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/jedkirby/tweet-entity-linker)[![StyleCI](https://camo.githubusercontent.com/ba251307f5647cd80bdfe4a280cbbb3e525b79faad3e5701a39cccc4f6ccba50/68747470733a2f2f7374796c6563692e696f2f7265706f732f37383139353631322f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/78195612)[![Packagist](https://camo.githubusercontent.com/df45db52f08427db5df1e788b6d6eeff5d826fcf6d16248f51f2814dbaafd5e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a65646b697262792f74776565742d656e746974792d6c696e6b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jedkirby/tweet-entity-linker)[![Packagist](https://camo.githubusercontent.com/db46d1113403d742366c31c8456247eb297daee3766c7b28286692881e7386cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a65646b697262792f74776565742d656e746974792d6c696e6b65722e7376673f7374796c653d666c61742d737175617265)](https://github.com/jedkirby/tweet-entity-linker/blob/master/LICENSE)

Tweet Entity Linker is a very simple package and requires minimal setup. It's designed to simply *only* convert a tweets text, along with it's entities, to a HTML rich string enabling linking of URLs, User Mentions and Hashtags.

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

[](#installation)

This package can be installed via [Composer](https://getcomposer.org/):

```
$ composer require jedkirby/tweet-entity-linker
```

It requires **PHP &gt;= 5.6.4**.

Usage
-----

[](#usage)

The following guide assumes that you've imported the class `Jedkirby\TweetEntityLinker\Tweet` into your namespace.

The `Tweet` class requires that you pass it parameters so it's able to create the linkified text. Generally these parameters will be the responses from Twitter API endpoints, like [statuses/show/:id](https://dev.twitter.com/rest/reference/get/statuses/show/id), however, it's not required.

The following pseudo code should help explain what's needed when using the response from the API (Please see the [example response](https://dev.twitter.com/rest/reference/get/statuses/show/id#example-response)):

```
$request = Api::get('https://api.twitter.com/1.1/statuses/show/123456');

$tweet = Tweet::make(
  $request['text'],
  $request['entities']['urls'],
  $request['entities']['user_mentions'],
  $request['entities']['hashtags'],
  $request['entities']['cashtags']
);
```

Now the `Tweet` class has been populated with the parameters it needs, you can call the `linkify()` method to return the text with URLs, User Mentions and Hashtags converted to their HTML entities:

```
$text = $tweet->linkify();
```

### Manually Creating Parameters

[](#manually-creating-parameters)

You're able to create the parametes manually, however, they require some specific properties in order for the `linkify()` method to function correctly, these are as follows:

#### Parameter 1: Text

[](#parameter-1-text)

This field is *always* required, and if containing either a URL, User Mention or Hashtag, the corresponding parameter array's should be populated. The following example assumes we have all of those:

```
$text = 'This notifies @jedkirby, with the hashtag #Awesome, and the URL https://t.co/Ed4omjYz.';
```

#### Parameter 2: URLs

[](#parameter-2-urls)

The URLs parameter is an array of array's, of which it must contain the `url` and `display_url` fields:

```
$urls = [
  [
    'url'         => 'https://t.co/Ed4omjYz',
    'display_url' => 'https://jedkirby.com'
  ]
];
```

#### Parameter 3: User Mentions

[](#parameter-3-user-mentions)

The User Mentions parameter is an array of array's, of which it must contain only a `screen_name` field:

```
$mentions = [
  [
    'screen_name' => 'jedkirby'
  ]
];
```

#### Parameter 4: Hashtags

[](#parameter-4-hashtags)

The Hashtags parameter is an array of array's, of which it must contain only a `text` field:

```
$hashtags = [
  [
    'text' => 'Awesome'
  ]
];
```

#### Parameter 5: Cashtags

[](#parameter-5-cashtags)

The Hashtags parameter is an array of array's, of which it must contain only a `text` field:

```
$cashtags = [
  [
    'text' => 'AAPL'
  ]
];
```

#### Result

[](#result)

When putting all the above parameters together, you'd get the following:

```
$tweet = Tweet::make(
  $text,
  $urls,
  $mentions,
  $hashtags,
  $cashtags
);

var_dump($tweet->linkify());
```

With the response being:

```
string(262) "This notifies @jedkirby, with the hashtag #Awesome, and the URL https://jedkirby.com."

```

Testing
-------

[](#testing)

Unit tests can be run inside the package:

```
$ ./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

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

License
-------

[](#license)

**jedkirby/tweet-entity-linker** is licensed under the MIT license. See the [LICENSE](LICENSE) file for more details.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 88.5% 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 ~218 days

Recently: every ~490 days

Total

10

Last Release

1448d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/67bc6fe497fd992d8dadbf6b3248aaf5651cfd020c3d435e8c2c9a209c2bc43b?d=identicon)[jedkirby](/maintainers/jedkirby)

---

Top Contributors

[![jedkirby](https://avatars.githubusercontent.com/u/1528691?v=4)](https://github.com/jedkirby "jedkirby (23 commits)")[![jxxe](https://avatars.githubusercontent.com/u/64276359?v=4)](https://github.com/jxxe "jxxe (2 commits)")[![Brunty](https://avatars.githubusercontent.com/u/1573273?v=4)](https://github.com/Brunty "Brunty (1 commits)")

---

Tags

convertentitytwitterLinkifyhashtagtweet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jedkirby-tweet-entity-linker/health.svg)

```
[![Health](https://phpackages.com/badges/jedkirby-tweet-entity-linker/health.svg)](https://phpackages.com/packages/jedkirby-tweet-entity-linker)
```

###  Alternatives

[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[iamcal/php-emoji

This is a PHP library for dealing with Emoji, allowing you to convert between various native formats and displaying them using HTML.

1.3k481.1k](/packages/iamcal-php-emoji)[gabrielelana/byte-units

Library to parse, format and convert byte units

1672.2M19](/packages/gabrielelana-byte-units)[arcanedev/seo-helper

SEO Helper is a framework agnostic package that provides tools &amp; helpers for SEO (Laravel supported).

332467.0k4](/packages/arcanedev-seo-helper)[khill/php-duration

Converts between colon formatted time, human-readable time and seconds

1611.7M20](/packages/khill-php-duration)[misd/linkify

Converts URLs and email addresses in text into HTML links

1122.9M10](/packages/misd-linkify)

PHPackages © 2026

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