spatie/emoji
Work with emoji in PHP without relying on your IDE/font. Use the Spatie\Emoji\Emoji class to access emoji as constants or friendly camelCase methods like Emoji::grinningFace(), or fetch all emojis via Emoji::all().
spatie/emoji package is a minimal, single-purpose utility for emoji handling (rendering, validation, and conversion). It aligns well with applications requiring emoji support in text processing, user-generated content (UGC), or chat/messaging systems without adding bloat.@emoji, @emojiList) simplify frontend rendering, reducing custom JS/CSS work.EmojiValidator) enable seamless integration with Laravel’s form requests and API validation pipelines.emoji:valid in Form Requests).composer require spatie/emoji
php artisan vendor:publish --provider="Spatie\Emoji\EmojiServiceProvider"
@emoji('😊') for rendering or @emojiList for bulk conversion.$this->validate($request, ['message' => 'emoji']);
Emoji for automatic conversion:
use Spatie\Emoji\Casts\Emoji;
protected $casts = [
'content' => Emoji::class,
];
composer.json for exact PHP/Laravel constraints.@emojiList in loops).utf8mb4).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Missing emoji font in browser | Emoji displays as □ or � | Provide polyfill (e.g., Twemoji) or fallback text. |
| Invalid emoji in user input | Validation fails; UX disruption | Use emoji:safe rule to allow partial emoji support. |
| Package deprecation | Breaking changes in future Laravel | Pin version in composer.json; fork if critical. |
| High-frequency emoji processing | CPU/memory spikes in batch jobs | Cache emoji lists; use queue workers. |
SELECT/INSERT).feature() helper to toggle emoji support gradually.How can I help you explore Laravel packages today?