euclid1990/php-ios-emoji

Laravel 5 的 iOS 表情符号解析器

1.0.0 2016-03-12 10:34 UTC

This package is not auto-updated.

Last update: 2024-09-26 01:20:23 UTC


README

Latest Stable Version Total Downloads License

Laravel 5 的 iOS 表情符号解析器。 cry

安装

需要 PHP 5.5+ 和 Laravel 5。

可以通过在项目的 composer.json 中要求 euclid1990/php-ios-emoji 包来使用 Composer 安装 PHP iOs Emoji 服务提供者。

{
    "require": {
        "laravel/framework": "5.*",
        "euclid1990/php-ios-emoji": "~1.0"
    },
    "minimum-stability": "stable"
}

使用 composer 安装此包

composer require euclid1990/php-ios-emoji

使用 composer update 更新您的包或使用 composer install 安装。

设置

引导

要使用表情符号服务提供者,您必须在引导 Laravel 应用程序时注册提供者。主要有两种方式可以实现。

config/app.php 中找到 providers 键并注册表情符号服务提供者。

    'providers' => [
        // ...
        'euclid1990\PhpIosEmoji\Providers\EmojiServiceProvider',
    ]

对于 Laravel 5.1+

    'providers' => [
        // ...
        euclid1990\PhpIosEmoji\Providers\EmojiServiceProvider::class,
    ]

config/app.php 中找到 aliases 键。

    'aliases' => [
        // ...
        'Emoji' => 'euclid1990\PhpIosEmoji\Facades\Emoji',
    ]

对于 Laravel 5.1+

    'aliases' => [
        // ...
        'Emoji' => euclid1990\PhpIosEmoji\Facades\Emoji::class,
    ]

公开资产

运行以下命令:它将所有表情图标图像和 style.css 文件移动到 /public/ios-emoji

php artisan vendor:publish --tag=public --force

添加样式表

添加我们为您准备的样式表。

<link rel="stylesheet" href="{{ asset('/ios-emoji/css/style.css') }}">

或使用助手

<link rel="stylesheet" href="{{ ios_emoji_css() }}">

用法

1. 示例

\Emoji::parse($text);
<!DOCTYPE html>
<html>
<head>
    <title>PHP iOS Emoji</title>
    <link rel="stylesheet" href="{{ ios_emoji_css() }}">
</head>
<body>
    <p>'Parse the emotions: :smiley: :smile: :baby: :blush: :relaxed: :wink: :heart_eyes: :kissing_heart: in this string.'</p>
    <p></p>
    <p>{!! \Emoji::parse('Parse the emotions: :smiley: :smile: :baby: :blush: :relaxed: :wink: :heart_eyes: :kissing_heart: in this string.') !!}</p>
</body>
</html>

结果

Preview

2. 使用助手

$text = "Parse the emotions: :smiley: :smile: in this string.";
// iOS Emoji Parser
ios_emoji($text);

参考

  1. 表情别名