{"id":22860120,"url":"https://github.com/steppinghat/php-emoji-detector","last_synced_at":"2025-07-21T03:34:37.471Z","repository":{"id":35089295,"uuid":"205308101","full_name":"SteppingHat/php-emoji-detector","owner":"SteppingHat","description":"Detect and validate emoji in an input string","archived":false,"fork":false,"pushed_at":"2025-03-12T08:16:31.000Z","size":188,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-20T11:07:54.039Z","etag":null,"topics":["emoji","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SteppingHat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-30T05:04:13.000Z","updated_at":"2025-03-12T08:19:23.000Z","dependencies_parsed_at":"2024-02-05T01:29:22.260Z","dependency_job_id":"9692fc45-55ce-4477-8a45-54073b5b406c","html_url":"https://github.com/SteppingHat/php-emoji-detector","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":0.05882352941176472,"last_synced_commit":"c591fce0bfdb547b4d4d160b753fb93e78cae1ae"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/SteppingHat/php-emoji-detector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteppingHat%2Fphp-emoji-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteppingHat%2Fphp-emoji-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteppingHat%2Fphp-emoji-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteppingHat%2Fphp-emoji-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SteppingHat","download_url":"https://codeload.github.com/SteppingHat/php-emoji-detector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteppingHat%2Fphp-emoji-detector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266235561,"owners_count":23897181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emoji","php"],"created_at":"2024-12-13T09:09:24.480Z","updated_at":"2025-07-21T03:34:37.451Z","avatar_url":"https://github.com/SteppingHat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHP Emoji Detector\n==================\n\n[![Latest Stable Version](https://poser.pugx.org/steppinghat/emoji-detector/v)](//packagist.org/packages/steppinghat/emoji-detector)\n[![Total Downloads](https://poser.pugx.org/steppinghat/emoji-detector/downloads)](//packagist.org/packages/steppinghat/emoji-detector)\n[![License](https://img.shields.io/packagist/l/steppinghat/emoji-detector)](//packagist.org/packages/steppinghat/emoji-detector)\n![Build Status](https://github.com/steppinghat/php-emoji-detector/actions/workflows/build_and_test.yml/badge.svg?branch=master)\n![Unicode Version](https://img.shields.io/badge/unicode-16.0-purple)\n\nHave an input string full of emoji's and you want to know detailed information about each emoji?\nWant to build an easy way to validate emoji's that come in as input data?\n\nThis :clap: is :clap: the :clap: library :clap: you :clap: want!\n\n## What does this thing do?\n\nThis 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 16.0 of the emoji standard.\n\n## Installation\n\nInstall this library using composer\n\n```\n$ composer require steppinghat/emoji-detector\n```\n\nℹ️ **We recommend using the [Caret Version Range (`^`)](https://getcomposer.org/doc/articles/versions.md#caret-version-range-)** (see below for why)\n\n### Updates\n\nUpdates to the Unicode version will always be released as new minor versions. We recommend using the (`^`)\ncaret version range so that new Emoji's are automatically supported in your project when running `composer update`.\n\nAny breaking changes will be released as new major versions, and bugfixes will be released as new patch versions as usual.\n\n## Usage\n\n- [PHP Emoji Detector](#php-emoji-detector)\n  - [What does this thing do?](#what-does-this-thing-do)\n  - [Installation](#installation)\n    - [Updates](#updates)\n  - [Usage](#usage)\n    - [The Model](#the-model)\n    - [Emoji detection](#emoji-detection)\n    - [Detect distinct emojis](#detect-distinct-emojis)\n    - [Testing for single emojis](#testing-for-single-emojis)\n    - [Testing if a string is completely emojis](#testing-if-a-string-is-completely-emojis)\n  - [Tests](#tests)\n  - [License](#license)\n\n### The Model\n\nFor most outputs, the library will provide an `EmojiInfo` object that contains all of the relevant information about an emoji.\nThe object will contain the following information:\n\n| Property    | Description |\n| ----------- | ----------- |\n| `emoji`     | The emoji chacater itself |\n| `name`      | A user friendly name of the specific emoji |\n| `shortName` | A shortened name of the emoji |\n| `category`  | A user friendly category name for the emoji |\n| `skinTone`  | The level of skin tone of the emoji (if present) |\n| `hexCodes`  | An array of individual hexadecimal characters that are used to make up the emoji |\n| `offset`    | The position in the string where the emoji starts |\n| `mbOffset`  | The multibyte position in the string where the emoji starts |\n\nAll of these properties are protected, but can be accessed by their appropriate getters and setters. E.g. `getCategory()` or `getSkinTone()`.\n\n\n### Emoji detection\n\n```php\n\u003c?php\n\nrequire_once('vendor/autoload.php');\n\nuse SteppingHat\\EmojiDetector\\EmojiDetector;\n\n$input = \"Hello 👋 world!\";\n$detector = new EmojiDetector();\n$emojis = $detector-\u003edetect($input);\n\nprint_r($emojis);\n```\nThis example is the most common usage of the detector, returning an array of objects that provide detailed information about each emoji found in the input string.\n\n```\nArray\n(\n    [0] =\u003e SteppingHat\\EmojiDetector\\Model\\EmojiInfo Object\n        (\n            [emoji:protected] =\u003e 👋\n            [name:protected] =\u003e waving hand\n            [shortName:protected] =\u003e hand-fingers-open\n            [category:protected] =\u003e People \u0026 Body\n            [skinTone:protected] =\u003e\n            [hexCodes:protected] =\u003e Array\n                (\n                    [0] =\u003e 1F44B\n                )\n\n            [offset:protected] =\u003e 6\n            [mbOffset:protected] =\u003e 6\n        )\n\n)\n```\n\nThe library has full support for complex emoji's that make use of the ZWJ (Zero Width Joiner) character.\n\n```php\n\u003c?php\n\nrequire_once('vendor/autoload.php');\n\nuse SteppingHat\\EmojiDetector\\EmojiDetector;\n\n$input = \"I ❤️ to 👨‍💻\";\n$detector = new EmojiDetector();\n$emojis = $detector-\u003edetect($input);\n\nprint_r($emojis);\n```\n\nThe above will produce the following output:\n\n```\nArray\n(\n    [0] =\u003e SteppingHat\\EmojiDetector\\Model\\EmojiInfo Object\n        (\n            [emoji:protected] =\u003e ❤️\n            [name:protected] =\u003e red heart\n            [shortName:protected] =\u003e emotion\n            [category:protected] =\u003e Smileys \u0026 Emotion\n            [skinTone:protected] =\u003e \n            [hexCodes:protected] =\u003e Array\n                (\n                    [0] =\u003e 2764\n                    [1] =\u003e FE0F\n                )\n\n            [offset:protected] =\u003e 2\n            [mbOffset:protected] =\u003e 2\n        )\n\n    [1] =\u003e SteppingHat\\EmojiDetector\\Model\\EmojiInfo Object\n        (\n            [emoji:protected] =\u003e 👨‍💻\n            [name:protected] =\u003e man technologist\n            [shortName:protected] =\u003e person-role\n            [category:protected] =\u003e People \u0026 Body\n            [skinTone:protected] =\u003e \n            [hexCodes:protected] =\u003e Array\n                (\n                    [0] =\u003e 1F468\n                    [1] =\u003e 200D\n                    [2] =\u003e 1F4BB\n                )\n\n            [offset:protected] =\u003e 13\n            [mbOffset:protected] =\u003e 9\n        )\n\n)\n```\n\n### Detect distinct emojis\n\nIf you only want to detect distinct emojis in a string, you can use the `detectDistinct` method. This will return an array of distinct emojis found in the input string, and the position of the first distinct occurence of that emoji.\n\n```php\n\u003c?php\n\nrequire_once('vendor/autoload.php');\n\nuse SteppingHat\\EmojiDetector\\EmojiDetector;\n\n$detector = new EmojiDetector();\n\n$emojis = $detector-\u003edetectDistinct(\"WHAT IS A KILOMETER 🗣🗣🗣🦅🦅🦅\")\n\nprint_r($emojis);\n```\n\nThe above will produce the following output:\n\n```\n(\n    [0] =\u003e SteppingHat\\EmojiDetector\\Model\\EmojiInfo Object\n        (\n            [emoji:protected] =\u003e 🗣\n            [name:protected] =\u003e speaking head\n            [shortName:protected] =\u003e person-symbol\n            [category:protected] =\u003e People \u0026 Body\n            [skinTone:protected] =\u003e \n            [hexCodes:protected] =\u003e Array\n                (\n                    [0] =\u003e 1F5E3\n                )\n\n            [offset:protected] =\u003e 20\n            [mbOffset:protected] =\u003e 20\n        )\n\n    [1] =\u003e SteppingHat\\EmojiDetector\\Model\\EmojiInfo Object\n        (\n            [emoji:protected] =\u003e 🦅\n            [name:protected] =\u003e eagle\n            [shortName:protected] =\u003e animal-bird\n            [category:protected] =\u003e Animals \u0026 Nature\n            [skinTone:protected] =\u003e \n            [hexCodes:protected] =\u003e Array\n                (\n                    [0] =\u003e 1F985\n                )\n\n            [offset:protected] =\u003e 32\n            [mbOffset:protected] =\u003e 23\n        )\n\n)\n```\n\n\n### Testing for single emojis\n\nSometimes it is handy to test if an input string is a single emoji on it's own.\n\n```php\n\u003c?php\n\nrequire_once('vendor/autoload.php');\n\nuse SteppingHat\\EmojiDetector\\EmojiDetector;\n\n$detector = new EmojiDetector();\n\n$detector-\u003eisSingleEmoji(\"💩\"); // Returns TRUE\n$detector-\u003eisSingleEmoji(\"Time to dance 🌚\"); // Returns FALSE\n$detector-\u003eisSingleEmoji(\"🍆🍒\"); // Returns FALSE\n```\n\n### Testing if a string is completely emojis\n\nSimilar to calling, `isSingleEmoji`, calling `isEmojiString` will check if a string only contains emojis.\n\n```php\n\u003c?php\n\nrequire_once('vendor/autoload.php')\n\nuse SteppingHat\\EmojiDetector\\EmojiDetector;\n\n$detector = new EmojiDetector();\n\n$detector-\u003eisEmojiString(\"😂😂😂\"); // Returns TRUE\n$detector-\u003eisEmojiString(\"🏎️💨\"); // Returns TRUE\n$detector-\u003eisEmojiString(\"Deez nuts 🥜\"); // Returns FALSE\n```\n\n## Tests\n\nIncluded for library development purposes is a small set of test cases to assure that basic library functions work as expected. These tests can be launched by running the following:\n\n```bash\n$ composer test\n```\n\nTo run tests against multiple PHP versions, either push to GitHub and open a PR, or preferrably use act locally:\n```bash\nact\n```\n\n## License\n\nMade with :heart: by Javan Eskander\n\nAvailable for use under the MIT license.\n\nIt includes data derived from the Unicode® Character Database, which is covered under the [Unicode License v3](https://www.unicode.org/license.html).\nThe Unicode® Standard is a trademark of Unicode, Inc. in the United States and other countries.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteppinghat%2Fphp-emoji-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteppinghat%2Fphp-emoji-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteppinghat%2Fphp-emoji-detector/lists"}