New in Symfony 6.2: Better Emoji Support 🎉

Contributed by
Grégoire Pineau
in #46755, #47263 and #47264.

Nowadays, you can find emojis everywhere: from email subjects and blog post titles, to messaging app reactions and website icons. You might think that they are silly, but their importance is increasing in business and other fields.

In Symfony 6.2, we're improving the Intl component and the String component to give you more tools to work with emojis. First, you can now transliterate the emoji description into any language thanks to the new EmojiTransliterator:

use Symfony\Component\Intl\Transliterator\EmojiTransliterator;

// describe emojis in English
$transliterator = EmojiTransliterator::create('en');
$transliterator->transliterate('Menus with 🍕 or 🍝');
// => 'Menus with pizza or spaghetti'

// describe emojis in Ukrainian
$transliterator = EmojiTransliterator::create('uk');
$transliterator->transliterate('Menus with 🍕 or 🍝');
// => 'Menus with піца or спагеті'

This transliterator can also convert emojis into their Slack or GitHub shortcode:

use Symfony\Component\Intl\Transliterator\EmojiTransliterator;

// describe emojis in Slack short code
$transliterator = EmojiTransliterator::create('slack');
$transliterator->transliterate('Menus with 🥗 or 🧆');
// => 'Menus with :green_salad: or :falafel:'

// use this to describe emojis in Github short code
// $transliterator = EmojiTransliterator::create('github');

In addition to this, the Symfony string slugger has been updated to slugify emojis into any language:

use Symfony\Component\String\Slugger\AsciiSlugger;

$slugger = new AsciiSlugger();
$slugger = $slugger->withEmoji();

$slug = $slugger->slug('a 😺, and a 🦁 go to 🏞️', '-', 'en');
// $slug = 'a-grinning-cat-and-a-lion-go-to-national-park';

$slug = $slugger->slug('un 😺, et un 🦁 vont au 🏞️', '-', 'fr');
// $slug = 'un-chat-qui-sourit-et-un-tete-de-lion-vont-au-parc-national';
            <hr style="margin-bottom: 5px" />
            <div style="font-size: 90%">
                <a href="https://symfony.com/sponsor">Sponsor</a> the Symfony project.
            </div>

https://symfony.com/blog/new-in-symfony-6-2-better-emoji-support?utm_source=Symfony%20Blog%20Feed&utm_medium=feed

Created 3y | Nov 2, 2022, 2:20:35 PM


Login to add comment

Other posts in this group

A Week of Symfony #960 (May 19–25, 2025)

This week, development activity focused on putting the final touches on Symfony 7.3 in preparation for its stable release next week. In addition, we published a security fix for a potential vulnerabil

May 25, 2025, 10:10:12 AM | Symfony
New in Symfony 7.3: New Bridges and Improved Integrations

Symfony's bridge packages integrate third-party services, such as mailers, notifiers, and translation providers, into Symfony applications. With more than 120 bridges available today, Symfony supports

May 23, 2025, 9:30:04 AM | Symfony
New in Symfony 7.3: Messenger Improvements

Symfony Messenger component keeps evolving to meet the needs of complex, modern applications. In Symfony 7.3, we're introducing several powerful features to it.

Run Process Using the Shell… https://s

May 22, 2025, 7:50:11 AM | Symfony
New in Symfony 7.3: Routing Improvements

The Routing component provides an impressive list of features to map incoming URLs to your application code. Symfony 7.3 pushes it even further with a set of new features that improve developer experi

May 21, 2025, 11:10:07 AM | Symfony
New in Symfony 7.3: JsonStreamer Component

Contributed by Mathias Arlaud in

May 20, 2025, 9:30:13 AM | Symfony
Symfony UX CVE-2025-47946: Unsanitized HTML attribute injection via ComponentAttributes

Affected versions

Symfony UX symfony/ux-live-component and symfony/ux-twig-component versions <2.25.1 are affected by this security issue.

The issue has been fixed in the 2.25.1 version of these

May 19, 2025, 12:40:14 PM | Symfony
New in Symfony 7.3: Yaml Improvements

Symfony has been reducing the need for configuration in applications for several years now. Thanks to PHP attributes, you can now configure most things alongside the relevant code, removing the need f

May 19, 2025, 8:10:09 AM | Symfony