LaravelEmoji-integrates Emoji in Laravel applications

Source: Internet
Author: User
Tags composer install
LaravelEmoji-integrates Emoji in Laravel applications 1. Introduction

Today, as social networks are so developed, Emoji forms are everywhere, including QQ, Weibo, and forums. As a developer, you may need to provide a variety of expressions in the application for users to comment and communicate.

PHP 5 supports converting Unicode strings to emoticon, but is complicated:

     

PHP 7 provides better support for Unicode strings, so we can display the emoticon more conveniently:

      

Of course, this encoding is unfriendly. we need to use a more readable way to display the expression. Fortunately, in Laravel, we can achieve this through the Laravel Emoji extension package.

2. Installation

System requirements: PHP 5.4 +/HHVM 3.3 +, Composer

To install Laravel Emoji of the latest version, declare the following dependencies in composer. json:

"unicodeveloper/laravel-emoji": "1.0.*"

Then run composer install or composer update to download and install the extension package.

After the installation is complete, you need to register the service provider. in the configuration file app. php, add the following code to the providers array:

Unicodeveloper\Emoji\EmojiServiceProvider::class

At the same time, do not forget to register the facade to the aliases array:

'aliases' => [        ...        'Emoji' => Unicodeveloper\Emoji\Facades\Emoji::class,    ...]
3. use

Laravel Emoji provides us with a variety of ways to display emojis, and then calls them through the Emoji facade in a unified manner:

       

For more Emoji expressions, see the complete list of Emoji expressions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.