PHPackages                             48design/phmiley - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. 48design/phmiley

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

48design/phmiley
================

Phmiley replaces Unicode emojis in UTF8 strings with graphics.

1.0.0(5y ago)025MITPHPPHP &gt;=7.1.0CI failing

Since Jul 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/48design/phmiley)[ Packagist](https://packagist.org/packages/48design/phmiley)[ RSS](/packages/48design-phmiley/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Phmiley [![Build Status](https://camo.githubusercontent.com/32a92adb26984316f9a466e5f05bbfd668689065d2036be01af2be1cc6870a26/68747470733a2f2f7472617669732d63692e636f6d2f343864657369676e2f70686d696c65792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/48design/phmiley) [![Coverage Status](https://camo.githubusercontent.com/26f8655057bc9c6a165aa2abd0a70396fbeb1bb286b9bb4373af2d2d0c628205/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f343864657369676e2f70686d696c65792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/48design/phmiley?branch=master)
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#phmiley--)

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
------------

[](#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
-----

[](#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 `` 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](https://48design.github.io/phmiley/demo/) 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
-------

[](#options)

### Presets

[](#presets)

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

Available presets:

presetresulttwemoji\_72 (default)Twemoji PNG graphics (72x72px) served via gitcdn.xyztwemoji\_svgTwemoji SVG graphics served via gitcdn.xyzopenmoji\_72OpenMoji PNG graphics (72x72px) served via jsdelivr.netopenmoji\_618OpenMoji PNG graphics (618x618px) served via jsdelivr.netopenmoji\_svgOpenMoji SVG graphics (72x72px) served via jsdelivr.net### Tag generator

[](#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](https://48design.github.io/phmiley/demo/) for example usage.

Licence
-------

[](#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](https://www.unicode.org/copyright.html) and [License](https://www.unicode.org/license.html) information.

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

- [Twemoji](https://github.com/twitter/twemoji) Copyright (c) 2018 Twitter, Inc and other contributors. License: [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- [OpenMoji](https://openmoji.org/) – the open-source emoji and icon project. License: [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/#)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2140d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1440241?v=4)[48DESIGN](/maintainers/48design)[@48design](https://github.com/48design)

---

Top Contributors

[![48design](https://avatars.githubusercontent.com/u/1440241?v=4)](https://github.com/48design "48design (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/48design-phmiley/health.svg)

```
[![Health](https://phpackages.com/badges/48design-phmiley/health.svg)](https://phpackages.com/packages/48design-phmiley)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
