承接 hdvinnie/laravel-joypixel-emojis 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hdvinnie/laravel-joypixel-emojis

最新稳定版本:v3.0.1

Composer 安装命令:

composer require hdvinnie/laravel-joypixel-emojis

包简介

Laravel helper for Joypixels emojis

README 文档

README

Software License Packagist Packagist Downloads

Laravel package to make it easier working with the modern emojis from Joypixels.

installation

Via Composer

$ composer require "hdvinnie/laravel-joypixel-emojis"
$ composer update

If you are on a Laravel that does not have Auto Discovery or you have it disabled then you need to add the following to your config/app.php file:

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

hdvinnie\LaravelJoyPixels\LaravelJoyPixelsServiceProvider::class,

Add this to the aliases array in config/app.php

'LaravelJoyPixels' => hdvinnie\LaravelJoyPixels\LaravelJoyPixelsFacade::class,

Config:

$ php artisan vendor:publish --tag=config --provider="hdvinnie\LaravelJoyPixels\LaravelJoyPixelsServiceProvider"

Usage

LaravelJoyPixels::toShort($str); // - native unicode -> shortnames
LaravelJoyPixels::shortnameToImage($str); // - shortname -> images
LaravelJoyPixels::unicodeToImage($str); // - native unicode -> images
LaravelJoyPixels::toImage($str); // - native unicode + shortnames -> images (mixed input)

Blade (equivalent to LaravelJoyPixels::toImage($str)):

@joypixels(':smile:') -> 😀

@joypixels(':smile: ❤️') -> 😀❤️

🚨 The output is not escaped so be careful with what you pass into @joypixels.

More details about how toImage($str) works can be found at 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 LaravelJoyPixels::toShort($str) to convert 😄 and other emoji to :smile: etc.

Comment::create([
  'content' => LaravelJoyPixels::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:

In your view where you display your comments you can use

@joypixels($comment->content)

and that will convert :smile: and 😄 to the emojione equivalent.

Assets

By default it will use the assets from JSDelivr.

Remember to run this before trying to publish any of the assets:

composer require joypixels/assets

If you want to serve the assets yourself you can publish them with the following commands. Remember to update config/joypixels.php

PNG files in sizes 32/64/128:

$ php artisan vendor:publish --tag=public --provider="hdvinnie\LaravelJoyPixels\LaravelJoyPixelsServiceProvider"

In config/joypixels.php specify the local path. Remember to specify which size you want in the path (32/64/128).

'imagePathPNG' => '/vendor/joypixels/png/64/',

Sprites

If you want to use sprites:

$ php artisan vendor:publish --tag=sprites --provider="hdvinnie\LaravelJoyPixels\LaravelJoyPixelsServiceProvider"

In config/joypixels.php enable sprites:

'sprites' => true,
'spriteSize' => 32, // 32 or 64

Add the stylesheet to your HTML:

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

统计信息

  • 总下载量: 64.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-09