itsnubix/emoji
Composer 安装命令:
composer require itsnubix/emoji
包简介
A PHP Library for interacting with Emojis
README 文档
README
Adds support for inserting and converting emojis into unicode in PHP. Uses enums and so requires PHP8.1 or higher.
Installation
composer require itsnubix/emoji
Usage
Below you will find some usage examples.
use Emoji\Emoji; use Emoji\SkinTone; // Globally set skin tone for all applicable emojis Emoji::setDefaultSkinTone(SkinTone::medium); // Various methods for spitting out a unicode emoji Emoji::get('grinning_face')->toString(); // returns 😀 (string) Emoji::grinning_face(); // returns 😀 echo Emoji::grinningFace(); // returns 😀 // Overwrite the default skin tone on the fly Emoji::get('waving_hand', SkinTone::light)->toString(); // returns 👋🏻 Emoji::wavingHand()->light()->toString(); // returns 👋🏻 Emoji::wavingHand()->skinTone('light')->toString(); // returns 👋🏻 // Also supports dynamic skin tone selection with a callback $user = new User(['preferred_skin_tone' => SkinTone::light]) Emoji::wavingHand() ->skinTone(fn() => $user->preferred_skin_tone) ->toString(); // You may also remove tone from a given emoji as well. $emoji = Emoji::wavingHand(SkinTone::medium); $emoji->skinTone(); // get the skin tone, returns SkinTone::medium $emoji->toneless()->skinTone(); // returns null // Finally, you may replace emojis in a string where they match within // two colons and align to an allowed emoji character. If invalid characters // are used it just returns them without converting Emoji::parse('Hello world :waving_hand: how are you :invalid_character:'); // returns "Hello world 👋" how are you :invalid_character:" // You can set the skin tone for the parser globally with... Emoji::setDefaultSkinTone(Emoji::light); Emoji::parse('Hello world :waving_hand:'); // returns "Hello world 👋🏻"
For a full list of supported emojis and those that support adding skin tones view: Character
For a full list of skin tones view: SkinTone
Todo
- Allow a user to select emojis
- Allow a user to set skin tones
- Add support for all emoji skin tones
- Add support for changing skin tone when replacing a string
itsnubix/emoji 适用场景与选型建议
itsnubix/emoji 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 239 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 itsnubix/emoji 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 itsnubix/emoji 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 239
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-17