PHPackages                             steppinghat/emoji-detector - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. steppinghat/emoji-detector

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

steppinghat/emoji-detector
==========================

Detect and validate emoji in an input string

1.10.0(3mo ago)26582.1k↑11.6%2[1 issues](https://github.com/SteppingHat/php-emoji-detector/issues)1MITPHPPHP &gt;=8.1CI passing

Since Aug 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/SteppingHat/php-emoji-detector)[ Packagist](https://packagist.org/packages/steppinghat/emoji-detector)[ Docs](https://github.com/steppinghat/emoji-detector)[ RSS](/packages/steppinghat-emoji-detector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (1)

PHP Emoji Detector
==================

[](#php-emoji-detector)

[![Latest Stable Version](https://camo.githubusercontent.com/caa833a59d95929a6828d70b822dec66666c6723d430ba437239120f3d5955e1/68747470733a2f2f706f7365722e707567782e6f72672f7374657070696e676861742f656d6f6a692d6465746563746f722f76)](//packagist.org/packages/steppinghat/emoji-detector)[![Total Downloads](https://camo.githubusercontent.com/131d645ed11912f0c9e770b1e36ff8c654e9adf8316d307329fee9b1760f4ca8/68747470733a2f2f706f7365722e707567782e6f72672f7374657070696e676861742f656d6f6a692d6465746563746f722f646f776e6c6f616473)](//packagist.org/packages/steppinghat/emoji-detector)[![License](https://camo.githubusercontent.com/518daea265ed81687390c7a917e580d75113ecfb8af57b1dd8ec63415114b792/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7374657070696e676861742f656d6f6a692d6465746563746f72)](//packagist.org/packages/steppinghat/emoji-detector)[![Build Status](https://github.com/steppinghat/php-emoji-detector/actions/workflows/build_and_test.yml/badge.svg?branch=master)](https://github.com/steppinghat/php-emoji-detector/actions/workflows/build_and_test.yml/badge.svg?branch=master)[![Unicode Version](https://camo.githubusercontent.com/e83f773e56c6868cca05fc03ef2d270f4e5b8ffa844298e6182cd40507721224/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f756e69636f64652d31372e302d707572706c65)](https://camo.githubusercontent.com/e83f773e56c6868cca05fc03ef2d270f4e5b8ffa844298e6182cd40507721224/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f756e69636f64652d31372e302d707572706c65)

Have an input string full of emoji's and you want to know detailed information about each emoji? Want to build an easy way to validate emoji's that come in as input data?

This 👏 is 👏 the 👏 library 👏 you 👏 want!

What does this thing do?
------------------------

[](#what-does-this-thing-do)

This library simply parses input strings and returns a list of relevant information about emoji's that are present in the string. It currently supports version 17.0 of the emoji standard.

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

[](#installation)

Install this library using composer

```
$ composer require steppinghat/emoji-detector

```

ℹ️ **We recommend using the [Caret Version Range (`^`)](https://getcomposer.org/doc/articles/versions.md#caret-version-range-)** (see below for why)

### Updates

[](#updates)

Updates to the Unicode version will always be released as new minor versions. We recommend using the (`^`) caret version range so that new Emoji's are automatically supported in your project when running `composer update`.

Any breaking changes will be released as new major versions, and bugfixes will be released as new patch versions as usual.

Usage
-----

[](#usage)

- [PHP Emoji Detector](#php-emoji-detector)
    - [What does this thing do?](#what-does-this-thing-do)
    - [Installation](#installation)
        - [Updates](#updates)
    - [Usage](#usage)
        - [The Model](#the-model)
        - [Emoji detection](#emoji-detection)
        - [Detect distinct emojis](#detect-distinct-emojis)
        - [Testing for single emojis](#testing-for-single-emojis)
        - [Testing if a string is completely emojis](#testing-if-a-string-is-completely-emojis)
    - [Tests](#tests)
    - [License](#license)

### The Model

[](#the-model)

For most outputs, the library will provide an `EmojiInfo` object that contains all of the relevant information about an emoji. The object will contain the following information:

PropertyDescription`emoji`The emoji chacater itself`name`A user friendly name of the specific emoji`shortName`A shortened name of the emoji`category`A user friendly category name for the emoji`skinTone`The level of skin tone of the emoji (if present)`hexCodes`An array of individual hexadecimal characters that are used to make up the emoji`offset`The position in the string where the emoji starts`mbOffset`The multibyte position in the string where the emoji startsAll of these properties are protected, but can be accessed by their appropriate getters and setters. E.g. `getCategory()` or `getSkinTone()`.

### Emoji detection

[](#emoji-detection)

```
