48design/phmiley 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

48design/phmiley

Composer 安装命令:

composer require 48design/phmiley

包简介

Phmiley replaces Unicode emojis in UTF8 strings with graphics.

README 文档

README

Phmiley is a PHP library that replaces Unicode emojis in UTF8 strings with graphics.

Why is this still needed with growing cross-device Emoji support?

The creation of this library was triggered by the use case of server-side PDF creation that didn't support Emojis and displayed them as ugly rectangles. Also, Windows does not support Emoji flags natively, so you need to work around that if you want to use flags based on Unicode in your project.

Installation

Use as a Composer package

composer require 48design/phmiley

or require the files from the src folder manually:

use FortyeightDesign\Phmiley\Phmiley;

require '/path/to/phmiley/src/Phmiley.php';
require '/path/to/phmiley/src/Exception.php';

Phmiley requires at least PHP version 7.1.0 in order to run.

Usage

The most simple usage of Phmiley is

$Phmiley = new Phmiley();
$testString = "I would love to have some 🍕 right now! 🤤"
$Phmiley->parse($testString);

By default, this will replace all emojis with <img> tags with their href pointing to Twitter's Twemoji graphics in PNG format (72x72) on gitcdn.xyz. Some inline styles will make sure that the emojis have a feasible size compared to the text surrounding them.

You can also use some predefined presets to switch to SVG or use OpenMoji graphics instead, or use local graphics from your server. You can even provide your own tag generator callback. See the Demo Code for some examples and the Options section for all possible options.

On first run (per Unicode version), Phmiley will automatically get the character ranges for all emojis from Unicode's emoji-data.txt and cache them as a regex in the directory /regexdata. The package provides a cached regex file for version 13.0. Switching the version manually via ->setVersion() hasn't been tested thoroughly and should not be relied on for now.

Options

Presets

$Phmiley = new Phmiley([
    'preset' => 'openmoji_svg'
]);
// or
$Phmiley->setPreset('openmoji_svg');

Available presets:

preset result
twemoji_72 (default) Twemoji PNG graphics (72x72px) served via gitcdn.xyz
twemoji_svg Twemoji SVG graphics served via gitcdn.xyz
openmoji_72 OpenMoji PNG graphics (72x72px) served via jsdelivr.net
openmoji_618 OpenMoji PNG graphics (618x618px) served via jsdelivr.net
openmoji_svg OpenMoji SVG graphics (72x72px) served via jsdelivr.net

Tag generator

If you want to get rid of the inline styles, move them to a class instead, add a wrapper around the icon, use a span with background image instead or any other usecase you can think of, you can provide your own tag generator callback. You can provide a callable in whatever form you please, that will receive a $data parameter, being an associative array with the following properties: emoji - The real UTF-8 string of the matched emoji code - A represantation of UTF-32 hex codes of all codepoints used in the emoji, joined by dashes; this will be used as the base file name for the default twemoji and openmoji integrations

See the Demo Code for example usage.

Licence

Phmiley's code itself is available under the terms of the MIT license.

The code ranges are extracted from Unicode's emoji-data.txt and other data files, © 2019 Unicode®, Inc. See their Terms of Use and License information.

When using the built-in presets that request Twemoji or OpenMoji graphics, you are required to attribute that usage accordingly:

48design/phmiley 适用场景与选型建议

48design/phmiley 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 06 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 48design/phmiley 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 48design/phmiley 我们能提供哪些服务?
定制开发 / 二次开发

基于 48design/phmiley 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-29