Coder Social home page Coder Social logo

emoji's Introduction

Programatically work with emoji characters

Latest Version on Packagist Software License Tests Total Downloads

In PHP, you can display emoji characters just by typing them:

echo "๐Ÿ˜ƒ";

This package provides some functionality to work with emojis if your IDE or used font can't render them correctly:

Emoji::grinningFace();

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

The best postcards will get published on the open source page on our website.

Install

You can install the package via composer:

composer require spatie/emoji

Usage

The Spatie\Emoji\Emoji-class contains character constants that may be used directly:

Emoji::CHARACTER_GRINNING_FACE;

Or you can use the shorter method by leaving off "character" and using camelCase:

Emoji::grinningFace();

If you want to get an array containing all emojis, you can use this method:

Emoji::all();

You can also use an ISO 3166 Alpha2 country code and get the appropriate flag for the country:

Emoji::countryFlag('be'); // ๐Ÿ‡ง๐Ÿ‡ช

This package contains Full Emoji List v13.1 based on https://unicode.org/Public/emoji/13.1/emoji-test.txt all methods and constants are auto-generated.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

We are accepting PRs that add characters to the class. Please use this list to look up the unicode value and the name of the character.

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Credits

About Spatie

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

License

The MIT License (MIT). Please see License File for more information.

emoji's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emoji's Issues

Laravel 8 Support

It would be great if this package update its support to Laravel 8!

Flags in Chrome

It seems that flag emojis are not showing in Chrome (using 86.0.4240.198). Firefox is ok.

image

Euro
{!! \Spatie\Emoji\Emoji::countryFlag('be') !!}
{!! \Spatie\Emoji\Emoji::grinningFace() !!}

What could be the reason? Am I missing something?

Method names starting with a number are invalid

/**
 * @method static string 1stPlaceMedal()
 * @method static string 2ndPlaceMedal()
 * @method static string 3rdPlaceMedal()
 */

They should be converted to first, second, third or prefixed with anything.

Calling for Emoji Dynamically

I am using Laravel 8 and attempting to use a accessor to pull an icon (something like "CHARACTER_GRINNING_FACE") from the database and provide the icon.

My desire is to handle this through the eloquent model.

When I tested getting an emoji (not dynamically) the icon is provided as expected.

dd(\Spatie\Emoji\Emoji::CHARACTER_GRINNING_FACE);

However when I attempt to add an accessor to my model I get an UnknownCharacter exception.

I have attempted to use the getCharacter() method on the emoji class, with no success.

The value passed into the accessor in this example is CHARACTER_GRINNING_FACE

public function getIconAttribute($value)
{
    return Emoji::getCharacter($value);
}

I have also attempted to call the Emoji class as shown below, with no success.

public function getIconAttribute($value)
{
    return call_user_func('\Spatie\Emoji\Emoji::'.$value);
}

The error I get each time is the following.

Spatie\Emoji\Exceptions\UnknownCharacter
Character CHARACTER_GRINNING_FACE does not exist


Any advice you might have for getting the emoji character dynamically based on data in a database would be greatly appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.