PHPackages                             aksafan/yii2-emoji-detection - 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. aksafan/yii2-emoji-detection

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

aksafan/yii2-emoji-detection
============================

Yii2 wrapper for aaronpk's Emoji Detection

2.1.3(3mo ago)43.8k↓50%1MITPHPPHP ^8.0CI failing

Since Aug 22Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/aksafan/yii2-emoji-detection)[ Packagist](https://packagist.org/packages/aksafan/yii2-emoji-detection)[ Docs](https://github.com/aksafan/yii2-emoji-detection)[ RSS](/packages/aksafan-yii2-emoji-detection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (13)Used By (0)

yii2-emoji-detection
====================

[](#yii2-emoji-detection)

Yii2 wrapper for aaronpk's Emoji Detection (). The library provides all aaronpk's Emoji Detection tools and features with various enhancements and Yii2 syntax.

[![Latest Stable Version](https://camo.githubusercontent.com/df1731fc0303595304483839020bac175e98a425ecdb768c97f8f0b08a16dbfc/68747470733a2f2f706f7365722e707567782e6f72672f616b736166616e2f796969322d656d6f6a692d646574656374696f6e2f762f737461626c65)](https://packagist.org/packages/aksafan/yii2-emoji-detection)[![Total Downloads](https://camo.githubusercontent.com/b71a072ebc6d3cfcfd28659c23ea363aed0e691ad2437fa1b358db96feb58299/68747470733a2f2f706f7365722e707567782e6f72672f616b736166616e2f796969322d656d6f6a692d646574656374696f6e2f646f776e6c6f616473)](https://packagist.org/packages/aksafan/yii2-emoji-detection)[![Build Status](https://camo.githubusercontent.com/395ad634639ad36a3f903c66c8c3818d09a9d26f6f88840d0f5d34c1462dc658/68747470733a2f2f7472617669732d63692e6f72672f616b736166616e2f796969322d656d6f6a692d646574656374696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aksafan/yii2-emoji-detection)

Installation
============

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/). Check the [composer.json](https://github.com/aksafan/yii2-emoji-detection/blob/master/composer.json) for this extension's requirements and dependencies. Read this [composer.json](https://github.com/aaronpk/emoji-detector-php/blob/master/composer.json) for source library requirements.

To install, either run

```
$ php composer.phar require aksafan/yii2-emoji-detection

```

or add

```
"aksafan/yii2-emoji-detection": "*"

```

to the `require` section of your `composer.json` file.

Configuration
-------------

[](#configuration)

To use this extension, you have to configure the EmojiDetector class in your application configuration:

```
return [
    //....
    'components' => [
        'emojiDetector' => [
             'class' => 'aksafan\emoji\source\EmojiDetector\EmojiDetector',
        ],
    ]
];
```

Also add this to your Yii.php file in the root directory of the project for IDE code autocompletion.

```
/**
 * Class WebApplication
 * Include only Web application related components here.
 *
 * @property \aksafan\emoji\source\EmojiDetector $emojiDetector
 */
class WebApplication extends yii\web\Application
{
}
```

Now u can get access to extension's methods through:

```
Yii::$app->emojiDetector
```

Basic Usage
-----------

[](#basic-usage)

### Detect Emoji

[](#detect-emoji)

```
$input = "Hello 👍🏼 World 👨‍👩‍👦‍👦";
$emoji = Yii::$app->emojiDetector->detectAll($input);

print_r($emoji);
```

The method returns an array with details about each emoji found in the string.

```
Array
(
  [0] => Array
    (
      [emoji] => 👨‍👩‍👦‍👦
      [short_name] => man-woman-boy-boy
      [num_points] => 7
      [points_hex] => Array
        (
          [0] => 1F468
          [1] => 200D
          [2] => 1F469
          [3] => 200D
          [4] => 1F466
          [5] => 200D
          [6] => 1F466
        )
      [hex_str] => 1F468-200D-1F469-200D-1F466-200D-1F466
      [skin_tone] =>
    )
  [1] => Array
    (
      [emoji] => 👍🏼
      [short_name] => +1
      [num_points] => 2
      [points_hex] => Array
        (
          [0] => 1F44D
          [1] => 1F3FC
        )

      [hex_str] => 1F44D-1F3FC
      [skin_tone] => skin-tone-3
    )
)

```

- `emoji` - The emoji sequence found, as the original byte sequence. You can output this to show the original emoji.
- `short_name` - The short name of the emoji, as defined by [Slack's emoji data](https://github.com/iamcal/emoji-data).
- `num_points` - The number of unicode code points that this emoji is composed of.
- `points_hex` - An array of each unicode code point that makes up this emoji. These are returned as hex strings. This will also include "invisible" characters such as the ZWJ character and skin tone modifiers.
- `hex_str` - A list of all unicode code points in their hex form separated by hyphens. This string is present in the [Slack emoji data](https://github.com/iamcal/emoji-data) array.
- `skin_tone` - If a skin tone modifier was used in the emoji, this field indicates which skin tone, since the `short_name` will not include the skin tone.

### Detect Emoji and return only one specific param

[](#detect-emoji-and-return-only-one-specific-param)

```
$input = "Hello 👍🏼 World 👨‍👩‍👦‍👦";
$emoji = Yii::$app->emojiDetector->detectAllWIthSingleParam($input, aksafan\emoji\source\EmojiDetector::EMOJI);

print_r($emoji);
```

The method returns an array with details about each emoji found in the string.

```
Array
(
  [0] => Array
    (
      👨‍👩‍👦‍👦
    )
  [1] => Array
    (
      👍🏼
    )
)

```

```
$input = "Hello 👍🏼 World 👨‍👩‍👦‍👦";
$emoji = Yii::$app->emojiDetector->detectAllWIthSingleParam($input, aksafan\emoji\source\EmojiDetector::SHORT_NAME);

print_r($emoji);
```

```
Array
(
  [0] => Array
    (
      man-woman-boy-boy
    )
  [1] => Array
    (
      +1
    )
)

```

Possible params:

- `aksafan\emoji\source\EmojiDetector::EMOJI` - The emoji sequence found, as the original byte sequence. You can output this to show the original emoji.
- `aksafan\emoji\source\EmojiDetector::SHORT_NAME` - The short name of the emoji, as defined by [Slack's emoji data](https://github.com/iamcal/emoji-data).
- `aksafan\emoji\source\EmojiDetector::NUM_POINTS` - The number of unicode code points that this emoji is composed of.
- `aksafan\emoji\source\EmojiDetector::POINTS_HEX` - An array of each unicode code point that makes up this emoji. These are returned as hex strings. This will also include "invisible" characters such as the ZWJ character and skin tone modifiers.
- `aksafan\emoji\source\EmojiDetector::HEX_STR` - A list of all unicode code points in their hex form separated by hyphens. This string is present in the [Slack emoji data](https://github.com/iamcal/emoji-data) array.
- `aksafan\emoji\source\EmojiDetector::SKIN_TONE` - If a skin tone modifier was used in the emoji, this field indicates which skin tone, since the `short_name` will not include the skin tone.

### Replace Emoji with given replacer

[](#replace-emoji-with-given-replacer)

```
$input = "Hello 👍🏼 World 👨‍👩‍👦‍👦";
$emoji = Yii::$app->emojiDetector->replaceEmojis($input); //Default replacer is ''
// "Hello  World "
```

```
$input = "Hello 👍🏼 World 👨‍👩‍👦‍👦";
$emoji = Yii::$app->emojiDetector->replaceEmojis($input, '1');
// "Hello 1 World 1"
```

```
$input = "0️⃣5️⃣5️⃣0️⃣";
$emoji = Yii::$app->emojiDetector->replaceEmojis($input, '2');
// "2222"
```

### Count Emojis in text

[](#count-emojis-in-text)

```
$input = "Hello 👍🏼 World 👨‍👩‍👦‍👦";
$emoji = Yii::$app->emojiDetector->countEmojis($input);
// 2
```

```
$input = "0️⃣5️⃣5️⃣0️⃣";
$emoji = Yii::$app->emojiDetector->countEmojis($input);
// 4
```

### Test if a string is a single emoji

[](#test-if-a-string-is-a-single-emoji)

Since simply counting the number of unicode characters in a string does not tell you how many visible emoji are in the string, determining whether a single character is an emoji is more involved.

```
$emoji = Yii::$app->emojiDetector->isSingleEmoji('👨‍👩‍👦‍👦');
// true
```

```
$emoji =Yii::$app->emojiDetector->isSingleEmoji('Emoji with text 👨‍👩‍👦‍👦');
// false
```

```
$emoji =Yii::$app->emojiDetector->isSingleEmoji('😻🐈');
// false
```

### Test if a string has one or more emoji

[](#test-if-a-string-has-one-or-more-emoji)

```
$emoji = Yii::$app->emojiDetector->isEmoji('👨‍👩‍👦‍👦');
// true
```

```
$emoji =Yii::$app->emojiDetector->isEmoji('Emoji with text 👨‍👩‍👦‍👦');
// true
```

```
$emoji =Yii::$app->emojiDetector->isEmoji('😻🐈');
// true
```

```
$emoji =Yii::$app->emojiDetector->isEmoji('Just text');
// false
```

### Get Emojis' map

[](#get-emojis-map)

```
$emoji = Yii::$app->emojiDetector->getEmojiMap();

print_r($emoji);
```

The method returns an array of key-values pairs of emoji hex unicode and its short (friendly) name.

```
Array
(
  [0023-FE0F-20E3] => hash
  [002A-FE0F-20E3] => keycap_star
  [0030-FE0F-20E3] => zero
  [0031-FE0F-20E3] => one
  [0032-FE0F-20E3] => two
  [0033-FE0F-20E3] => three
  [0034-FE0F-20E3] => four
  [0035-FE0F-20E3] => five
  ...
  [2B55] => o
  [3030-FE0F] => wavy_dash
  [303D-FE0F] => part_alternation_mark
  [3297-FE0F] => congratulations
  [3299-FE0F] => secret
)

```

### Get Emojis' regexp. The method returns a string with regexp (build on emojis' map) to detect emojis

[](#get-emojis-regexp-the-method-returns-a-string-with-regexp-build-on-emojis-map-to-detect-emojis)

```
$emoji = Yii::$app->emojiDetector->getEmojiRegexp();
// "/(?:\x{1F468}\x{200D}\x{2764}\x{FE0F}\x{200D}\x{1F48B}\x{200D}\x{1F468}|\x{1F469}\x{200D}\x{2764}\x{FE0F}\x{200D}\x{1F48B}\x{200D}\x{1F469}|\x{1F469}\x{200D}\x{2764}\x{FE0F}\x{200D}\x{1F48B}\x{200D}\x{1F468}|\x{1F3F4}\x{E0067}\x{E0062}\x{E0073}\x{E0063}\x{E0074}\x{E007F}|\x{1F3F4}\x{E0067}\x{E0062}\x{E0065}\x{E006E}\x{E0067}\x{E007F}|\x{1F3F4}\x{E0067}\x{E0062}\x{E0077}\x{E006C}\x{E0073}\x{E007F}...)"
```

License
-------

[](#license)

Copyright 2018 by Anton Khainak.

Available under the MIT license.

Emoji Detection data sourced from [aaronpk/emoji-detector-php](https://github.com/aaronpk/emoji-detector-php) under the MIT license.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance79

Regular maintenance activity

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity74

Established project with proven stability

 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 ~301 days

Recently: every ~243 days

Total

10

Last Release

110d ago

Major Versions

1.3.0 → 2.0.02023-05-31

PHP version history (2 changes)1.0.0PHP &gt;=7.1

2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/84e4a3e60ef46466673c12a282b0fb0ca29f46c13fd072be7c9a276d3652a373?d=identicon)[Aksafan](/maintainers/Aksafan)

---

Top Contributors

[![aksafan](https://avatars.githubusercontent.com/u/14964793?v=4)](https://github.com/aksafan "aksafan (11 commits)")

---

Tags

yii2emojidetection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aksafan-yii2-emoji-detection/health.svg)

```
[![Health](https://phpackages.com/badges/aksafan-yii2-emoji-detection/health.svg)](https://phpackages.com/packages/aksafan-yii2-emoji-detection)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

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