PHPackages                             unicorn-fail/emoji - 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. unicorn-fail/emoji

ActiveLibrary

unicorn-fail/emoji
==================

Comprehensive PHP parser of emoticons, HTML entities, shortcodes and unicodes (emojis).

1335.0k1[2 PRs](https://github.com/unicorn-fail/emoji/pulls)1PHP

Since Mar 18Pushed 1y ago2 watchersCompare

[ Source](https://github.com/unicorn-fail/emoji)[ Packagist](https://packagist.org/packages/unicorn-fail/emoji)[ RSS](/packages/unicorn-fail-emoji/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (1)

league/emoji
============

[](#leagueemoji)

> [![Latest Version](https://camo.githubusercontent.com/0f3132ab548ed1dcac2f8c77aeddeb07874cf84a518c7bef0599443094519436/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f756e69636f726e2d6661696c2f656d6f6a692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unicorn-fail/emoji)[![Total Downloads](https://camo.githubusercontent.com/59c00f93a6bb91eda5af05dc1ee54770b90e8f255395f89ac8ec47f1c3f335aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f756e69636f726e2d6661696c2f656d6f6a692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unicorn-fail/emoji)[![Packagist PHP Version Support](https://camo.githubusercontent.com/0d4353b6798f2aa815b3bf44f7d4ad2d29cc26ae7e8665961f59e7c77dadf74c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f756e69636f726e2d6661696c2f656d6f6a693f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unicorn-fail/emoji)[![Software License](https://camo.githubusercontent.com/15c89e5a3cb71c8caa32884e01fe83f3b0384f4703fe4fe31d95882d12b896e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4253442d2d332d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)
> [![Build Status](https://camo.githubusercontent.com/6f5c5b0036f4264e69006d13ef7c25ee43302a7a66205e435b4ef1db7fd9fe3e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f756e69636f726e2d6661696c2f656d6f6a692f54657374732f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/unicorn-fail/emoji/actions?query=branch%3Amain)[![Scrutinizer coverage (GitHub/BitBucket)](https://camo.githubusercontent.com/9bd8c759c4bd0c5a4e8f0c6da5c3b613260f8022e5e7edf9b8713d2414e220a4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f756e69636f726e2d6661696c2f656d6f6a692f6d61696e3f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/unicorn-fail/emoji/?branch=main)[![Scrutinizer code quality (GitHub/Bitbucket)](https://camo.githubusercontent.com/a977d23156de84c3612734e8c5a620a4098a303ff7dc602056479620324fc6cf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f756e69636f726e2d6661696c2f656d6f6a692f6d61696e3f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/unicorn-fail/emoji/?branch=main)[![CII Best Practices Summary](https://camo.githubusercontent.com/48e4038c1681e70e40744e325464cf524ccbd01ec641e572d54246b8283f634d/68747470733a2f2f696d672e736869656c64732e696f2f6369692f73756d6d6172792f343238363f7374796c653d666c61742d737175617265)](https://bestpractices.coreinfrastructure.org/en/projects/4286)[![Psalm coverage](https://camo.githubusercontent.com/c64391b21e307ffec00d172425a6e3570b524a9af60a197abc86ba31de30a64e/68747470733a2f2f73686570686572642e6465762f6769746875622f756e69636f726e2d6661696c2f656d6f6a692f636f7665726167652e737667)](https://shepherd.dev/github/unicorn-fail/emoji)
>
> **league/emoji** is a comprehensive PHP parser and converter of emoticons, HTML entities, shortcodes and unicodes (emojis); utilizing [milesj/emojibase](https://github.com/milesj/emojibase) as its data source.

📦 Installation &amp; Basic Usage
--------------------------------

[](#-installation--basic-usage)

This project requires PHP 7.2.5 or higher with the `mbstring` and `zlib` PHP extensions. To install it via [Composer](https://getcomposer.org/) simply run:

```
$ composer require league/emoji
```

> **NOTE:** Until this is actually published in the `league` namespace on packagist.com, you will need to add the following to your `composer.json` file:
>
> ```
>     "repositories": [
>         {
>             "type": "vcs",
>             "url": "https://github.com/unicorn-fail/emoji.git"
>         }
>     ],
>     "require": {
>         "league/emoji": "dev-main"
>     }
> ```

The `League\Emoji\Emoji` class provides a simple wrapper for converting emoticons, HTML entities and shortcodes to proper unicode characters (emojis):

```
use League\Emoji\EmojiConverter;
use League\Emoji\Emojibase\EmojibaseDatasetInterface;
use League\Emoji\Emojibase\EmojibaseShortcodeInterface;

$defaultConfiguration = [
    /** @var array (see EmojiConverter::TYPES) */
    'convert' => [
        EmojiConverter::EMOTICON    => EmojiConverter::UNICODE,
        EmojiConverter::HTML_ENTITY => EmojiConverter::UNICODE,
        EmojiConverter::SHORTCODE   => EmojiConverter::UNICODE,
        EmojiConverter::UNICODE     => EmojiConverter::UNICODE,
    ],

    /** @var array */
    'exclude' => [
        /** @var string[] */
        'shortcodes' => [],
    ],

    /** @var string */
    'locale' => 'en',

    /** @var ?bool */
    'native' => null, // Auto (null), becomes true or false depending on locale set.

    /** @var int */
    'presentation' => EmojibaseDatasetInterface::EMOJI,

    /** @var string[] */
    'preset' => EmojibaseShortcodeInterface::DEFAULT_PRESETS,
];

// Convert all applicable values to unicode emojis (default configuration).
$converter = EmojiConverter::create();
echo $converter->convert('We
