2017 © Pedro Pelรกez
 

library laravel-emojione

Laravel helper for EmojiOne

image

christofferok/laravel-emojione

Laravel helper for EmojiOne

  • Wednesday, January 17, 2018
  • by christofferok
  • Repository
  • 3 Watchers
  • 80 Stars
  • 9,507 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 10 Versions
  • 23 % Grown

The README.md

laravel-emojione โค๏ธ

Latest Version on Packagist ![Total Downloads][ico-downloads] ![Software License][ico-license], (*1)

๐Ÿ˜€ ๐Ÿ‹๐Ÿผ โค๏ธ โ˜ฎ, (*2)

Laravel package to make it easier working with the gorgeous emojis from EmojiOne., (*3)

Remember to read the EmojiOne Free License and provide the appropriate attribution. Or buy a premium license, (*4)

Upgrading from 3.x to 4.x

  1. Update your composer dependency to: "christofferok/laravel-emojione": "^4.0" and run composer update
  2. Update config/emojione.php (if you have one) with 'emojiVersion' => '4.0'

If you are serving the assets yourself then you need to do the following things:, (*5)

  1. Update your emojione/assets composer dependency to: "emojione/assets": "^4.0" and run composer update
  2. Update config/emojione.php with the correct paths and versions
  3. Publish the assets again. See "Assets" section further down

EmojiOne 4.x/3.x vs 2.0

EmojiOne made a lot of changes in their licensing and which resources are provided in the free license. v2 code is still available in the emojione-v2 branch. If you are upgrading this package, be aware that the SVG assets are not available anymore., (*6)

Install

Via Composer, (*7)

``` bash $ composer require christofferok/laravel-emojione, (*8)

__If you are on Laravel 5.4 or lower you need to add the following to your `config/app.php` file:__

Add the ServiceProvider to the providers array in `config/app.php`

``` php
ChristofferOK\LaravelEmojiOne\LaravelEmojiOneServiceProvider::class,

Add this to the aliases array in config/app.php, (*9)

``` php 'LaravelEmojiOne' => ChristofferOK\LaravelEmojiOne\LaravelEmojiOneFacade::class,, (*10)


Config: ``` bash $ php artisan vendor:publish --tag=config --provider="ChristofferOK\LaravelEmojiOne\LaravelEmojiOneServiceProvider"

Usage

``` php LaravelEmojiOne::toShort($str); // - native unicode -> shortnames LaravelEmojiOne::shortnameToImage($str); // - shortname -> images LaravelEmojiOne::unicodeToImage($str); // - native unicode -> images LaravelEmojiOne::toImage($str); // - native unicode + shortnames -> images (mixed input), (*11)


Blade (equivalent to `LaravelEmojiOne::toImage($str)`): `@emojione(':smile:')` -> <img alt="๐Ÿ˜€" width="20" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/64/1f600.png"> `@emojione(':smile: โค๏ธ')` -> <img alt="๐Ÿ˜€" width="20" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/1f600.png"><img alt="โค๏ธ" width="20" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/2764.png"> ๐Ÿšจ The output is not escaped so be careful with what you pass into `@emojione`. More details about how `toImage($str)` works can be found at [https://github.com/Ranks/emojione/blob/master/examples/PHP.md](https://github.com/Ranks/emojione/blob/master/examples/PHP.md) ### Example You want to let users put emoji a comment. When you are saving a comment, you might want to run the content through `LaravelEmojiOne::toShort($str)` to convert `๐Ÿ˜„` and other emoji to `:smile:` etc. ```php Comment::create([ 'content' => LaravelEmojiOne::toShort(request('content')) ]);

So if someone leaves a comment like This is an awesome comment ๐Ÿ˜„๐Ÿ”ฅ it will be saved as This is an awesome comment :smile: :fire:, (*12)

In your view where you display your comments you can use, (*13)

@emojione($comment->content)

and that will convert :smile: and ๐Ÿ˜„ to the emojione equivalent., (*14)

Assets

By default it will use the assets from JSDelivr., (*15)

Remember to run this before trying to publish any of the assets:, (*16)

composer require emojione/assets

If you want to serve the assets yourself you can publish them with the following commands. Remember to update config/emojione.php, (*17)

PNG files in sizes 32/64/128:, (*18)

``` bash $ php artisan vendor:publish --tag=public --provider="ChristofferOK\LaravelEmojiOne\LaravelEmojiOneServiceProvider", (*19)


In `config/emojione.php` specify the local path. Remember to specify which size you want in the path (32/64/128). ```php 'imagePathPNG' => '/vendor/emojione/png/64/',

Sprites

If you want to use sprites:, (*20)

``` bash $ php artisan vendor:publish --tag=sprites --provider="ChristofferOK\LaravelEmojiOne\LaravelEmojiOneServiceProvider", (*21)


In `config/emojione.php` enable sprites: ```php 'sprites' => true, 'spriteSize' => 32, // 32 or 64

Add the stylesheet to your HTML:, (*22)

<link rel="stylesheet" href="/vendor/emojione/sprites/emojione-sprite-{{ config('emojione.spriteSize') }}.min.css"/>

License

Remember to read the EmojiOne Free License and provide the appropriate attribution. Or buy a premium license, (*23)

The Versions

17/01 2018

dev-master

9999999-dev https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

17/01 2018

2.1.3

2.1.3.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

22/07 2017

2.1.2

2.1.2.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

11/07 2017

2.1.1

2.1.1.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

04/07 2017

2.1.0

2.1.0.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

03/05 2017

2.0.1

2.0.1.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

27/04 2017

dev-emojione-v2

dev-emojione-v2 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

27/04 2017

2.0.0

2.0.0.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

18/02 2017

1.0.1

1.0.1.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione

16/02 2017

1.0.0

1.0.0.0 https://github.com/christofferok/LaravelEmojiOne

Laravel helper for EmojiOne

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel emoji emojione christofferok laravelemojione