deniskorbakov / emoji-php
Library for Emoji in PHP - replacement, search, transformation by CLDR
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/deniskorbakov/emoji-php
Requires
- php: >=8.4
Requires (Dev)
- milesj/emojibase: ^16.0
- mockery/mockery: ^1.6
- pestphp/pest: ^3.8 || ^4.0
- phpstan/phpstan: ^2.1
- rector/rector: *
- slevomat/coding-standard: ^8.20
- squizlabs/php_codesniffer: ^3.13 || ^4.0
README
โจ Supports CLDR emoticon storage standard
๐ Multilingual search from 25 languages
๐ช Replacing unicode emoticons in CLDR format and vice versa
@ This library uses a database of emoticons from - link
๐ Getting Started
Install the package via composer:
composer require deniskorbakov/emoji-php
Now you can use the class with emoticons:
use DenisKorbakov\EmojiPhp\Emojis; new Emojis();
Below we will consider the functionality of this class.
๐ Examples & Usage
This method outputs a grouping of emoticons with a cldr code based on the selected language
use DenisKorbakov\EmojiPhp\Emojis; use DenisKorbakov\EmojiPhp\Locale; new Emojis()->list(Locale::EN); // return ['smileys & emotion' => ['๐' => ':grinning_face:', ...]]
This method converts the unicode of the emoji to the cldr code - we get unicode emoji from the list method
use DenisKorbakov\EmojiPhp\Emojis; $text = 'Hello, world! ๐๏ธ' new Emojis()->toCode($text); // return 'Hello, world! :globe_showing_europe_africa:'
This method converts the one unicode emoji to the cldr code - we get unicode emoji from the list method
use DenisKorbakov\EmojiPhp\Emojis; $emoji = '๐' new Emojis()->codeByEmoji($text); // return ':globe_showing_europe_africa:'
This method converts from cldr code with text to unicode emojis - we get cldr from the list method
use DenisKorbakov\EmojiPhp\Emojis; $text = 'Hello :waving_hand:'; new Emojis()->toEmoji($text); // return 'Hello ๐'
This method converts one cldr code to unicode emoji - we get cldr from the list method
use DenisKorbakov\EmojiPhp\Emojis; $text = ':waving_hand:'; new Emojis()->emojiByCode($text); // return '๐'
This method searches for emoticons by the word, and you also explicitly specify which language to search in
use DenisKorbakov\EmojiPhp\Emojis; use DenisKorbakov\EmojiPhp\Locale; $searchText = 'shoe' new Emojis()->search(Locale::EN, $searchText); // return ['๐' => ':mans_shoe:', ...]
โ๏ธ Local Development
Clone this repository:
git clone https://github.com/deniskorbakov/emoji-php
Let's go to the cloned repository:
cd emoji-php
To start, initialize the project and use it:
make init
๐งช Testing
You can run the command for testing after the step with local installation
Run Lint and Analyze code(phpstan/rector/phpcs):
make lint
Run Unit tests:
make test
Run test coverage:
make test-coverage
๐ค Feedback
We appreciate your support and look forward to making our product even better with your help!
๐ Generated from deniskorbakov/skeleton-php-docker