overtrue/laravel-emoji
Laravel integration for the overtrue/emoji library that converts shortcodes like :smile: into unicode emoji or images. Ships with a facade, Blade directive, helper function, and configurable conversion drivers, making it easy to render emoji consistently across views, models, and API responses.
composer why-not overtrue/laravel-emoji ^3.0 before anything else — on Laravel 11/12 apps this will hard-block, and 2.x is now the maintenance branch for those.composer require overtrue/laravel-emoji:^3.0. The service provider is auto-discovered; no manual registration needed.php artisan vendor:publish --tag=<tag from README>. Use the tag printed in the 3.0 README — the previously documented tag was wrong, so any copy-pasted snippet from a blog post or an old issue is likely to fail silently.{{-- shortcode -> unicode, in prose --}}
<p>{{ emoji($comment->body) }}</p>
{{-- or as a directive --}}
@emoji($comment->body)
config/emoji.php (the client entry — should now resolve to JoyPixels), the service provider's container binding for the client class, and the README's corrected class name. If you previously subclassed or rebound the client, verify the FQCN against 3.0.:smile: in the database and convert at render time. It's reversible, diff-friendly, and lets you re-render historical content if the client's emoji set changes.emoji() behind a small EmojiFormatter service (or a HasEmoji trait / accessor) so views never call the helper directly. This gives you one place to swap clients, one place to add caching, and one place to disable conversion in tests.->through() collection callback rather than in the controller, so paginated and single-resource responses stay consistent.<x-emoji-text :text="$body" /> component. That component is where you decide about escaping and about skipping <code>/<pre> blocks.utf8mb4 / utf8mb4_unicode_ci before you start converting output — otherwise the render works but the write path truncates.:smile:, mixed text, unknown shortcode, adjacent emoji) in a unit test against your wrapper — not against the vendor helper — so a future client swap shows up as one failing test rather than a hundred.emoji() and @emoji previously resolved the obsolete Emojione client; in 3.0 they resolve JoyPixels. Output for a given shortcode can differ in glyph and in coverage. If you have golden-file tests, HTML snapshots, or cached rendered fragments, re-baseline them once on upgrade.config/emoji.php, run php artisan config:clear (or re-run config:cache). A stale cached config is the #1 cause of "the fix didn't apply."10:30:), ratios, and ::class in code samples. Scope conversion to user-authored fields; never run it over a whole rendered page or over anything containing code.{{ }} will entity-encode any HTML the client emits; @emoji / {!! !!} will not. Pick one and document it in the wrapper. Never feed untrusted HTML through an unescaped path just to get emoji.cghooks install failure, delete it — it's dead weight now and may conflict with normal installs.composer require overtrue/laravel-emoji:^3.0, re-publish or diff the config, confirm the client class in the container is JoyPixels, clear config cache, re-baseline emoji snapshots, and drop any cghooks workaround.How can I help you explore Laravel packages today?