Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Emoji Bundle Laravel Package

oh/emoji-bundle

oh/emoji-bundle adds emoji support to PHP applications, making it easier to work with emoji characters and shortcodes in content, templates, and user input. It simplifies parsing, rendering, and handling emoji data so Laravel and PHP developers can build emoji-friendly features without custom logic.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Verify the composer name first. The repo is ollieLtd/OhEmojiBundle, but the Packagist name is not guaranteed to be ollie/oh-emoji-bundle. Run composer show --all against the repo or check the README before committing.
  • Read composer.json before installing. This is a Symfony bundle, not a Laravel package. Check whether it requires symfony/framework-bundle, symfony/dependency-injection, or symfony/twig-bundle — those pull in dead weight and may conflict with illuminate/* versions in a Laravel app.
  • Find the converter class. Look in src/ for the service that actually does the unicode → HTML/CSS mapping (likely something like EmojiConverter, EmojiTwigExtension, and a DependencyInjection/Configuration.php). If the converter has no Symfony container dependencies, you can use it directly and ignore the bundle plumbing. If it does, extract the converter into your own App\Support\Emoji class.
  • Check the config options in DependencyInjection/Configuration.php: sprite path, class prefix, image size, and whether it emits <span> vs <img>. Those map to your config/emoji.php.
  • First use case: render user-generated content (comments, chat, activity feed, post bodies) as consistent emoji across browsers by converting at render time into <span class="emoji emoji-…"></span> or <img> tags.
  • Publish the sprite/CSS (whatever the bundle ships) to public/ and include it in your base layout — without it you get empty spans.

Implementation Patterns

  • Blade helper + directive. Wrap the converter in a singleton and register @emoji($text) in AppServiceProvider::boot(). Prefer this over a global function so you can mock it in tests.
  • Store unicode, convert at render. Keep raw emoji in the DB column; run the converter in an accessor (getBodyHtmlAttribute()) or in the view. Changing sprite/class prefix later should never require a data migration.
  • API transformers. Convert in an ApiResource::toArray() so mobile clients get the same HTML the web sees, rather than pushing sprite assets to every client.
  • Cache the conversion. String scanning on long post bodies adds up. Cache by hash('xxh3', $raw) in Redis for repeated strings (e.g., comment bodies in a hot feed).
  • Response middleware as a fallback. For legacy routes you can't edit, add a middleware that converts only text/html responses on an allowlist of paths.
  • Bind the converter behind your own interface (App\Contracts\EmojiConverter) and register the package implementation in a service provider. This is your escape hatch if the package is abandoned.
  • Golden-file tests. Keep fixtures under tests/fixtures/emoji/ covering: plain text, single emoji, skin-tone modifiers, ZWJ sequences (family, profession), flags (regional indicator pairs), variation selectors, existing HTML entities, and mixed emoji + <script> to prove escaping still works.

Gotchas and Tips

  • Framework mismatch is the headline. A Symfony bundle in Laravel means no auto-registration, and possibly pulling Symfony components you don't want. If the converter is coupled to the container, either vendor just the converter class or pick a Laravel-native alternative.
  • Zero stars, zero dependents = no safety net. Pin the exact version, vendor the converter if the package disappears, and audit the source for anything network- or eval-based.
  • Store unicode, never the HTML. Persisted <span class="emoji-…"> markup locks you into the current sprite and class naming forever.
  • Grapheme clusters break naive regex. Emoji are frequently multi-codepoint: skin tones (U+1F3FB–1F3FF), ZWJ joins (U+200D), flags (two regional indicators), variation selector U+FE0F. If the package uses simple mb_str_split, expect missed or double conversions on these. Test them explicitly.
  • The output is unescaped HTML. In Blade, {!! emoji($text) !!} is only safe if $text was already escaped before conversion. Escape input, then convert — never the other way around.
  • Idempotency. Running the converter twice on already-converted text may double-wrap spans or skip them entirely. Either guard with a marker or ensure conversion only runs once per pipeline stage.
  • Assets are a hard dependency. If the CSS/sprite isn't published and included, emoji silently render as empty boxes — a common "it works in tinker but not the browser" bug.
  • Performance on long content. Character-by-character scanning is O(n); paginate conversion or cache results for feeds. Don't convert in a loop over thousands of rows.
  • Extension point: formatter/registry. If the package exposes a formatter or driver interface, implement it to register custom sets (Slack-style shortcodes, brand emoji) rather than forking.
  • Debugging tip: if output looks unchanged, dump the hex of the input — a missing U+FE0F variation selector or a non-UTF-8 column collation is the usual culprit. A small tinker command that shows input codepoints vs output HTML will save hours.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core