master d9f8d8ce22b7 cached
9 files
12.4 KB
3.6k tokens
12 symbols
1 requests
Download .txt
Repository: christofferok/laravel-emojione
Branch: master
Commit: d9f8d8ce22b7
Files: 9
Total size: 12.4 KB

Directory structure:
gitextract_slq4sk2c/

├── .editorconfig
├── .gitignore
├── LICENSE.md
├── README.md
├── composer.json
├── config/
│   └── emojione.php
└── src/
    ├── LaravelEmojiOne.php
    ├── LaravelEmojiOneFacade.php
    └── LaravelEmojiOneServiceProvider.php

================================================
FILE CONTENTS
================================================

================================================
FILE: .editorconfig
================================================
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false


================================================
FILE: .gitignore
================================================
/node_modules
/vendor
composer.lock
.DS_Store


================================================
FILE: LICENSE.md
================================================
# The MIT License (MIT)

Copyright (c) 2017 Christoffer Korvald <korvald@gmail.com>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.


================================================
FILE: README.md
================================================
# laravel-emojione <img alt="❤️" width="30" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/2764.png">

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]
[![Software License][ico-license]](LICENSE.md)

<img alt="😀" width="50" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/1f600.png"> <img alt="🏋🏼" width="50" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/1f3cb-1f3fc.png"> <img alt="❤️" width="50" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/2764.png"> <img alt="☮" width="50" src="https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/262e.png">


Laravel package to make it easier working with the gorgeous emojis from [EmojiOne](https://emojione.com/). 

Remember to read the [EmojiOne Free License](https://www.emojione.com/licenses/free) and provide the appropriate attribution. Or buy a  [premium license](https://www.emojione.com/licenses/premium)

## 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:

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](https://github.com/christofferok/laravel-emojione/tree/emojione-v2) branch. If you are upgrading this package, be aware that the SVG assets are not available anymore. 

## Install

Via Composer

``` bash
$ composer require christofferok/laravel-emojione
```
__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`

``` php
'LaravelEmojiOne' => ChristofferOK\LaravelEmojiOne\LaravelEmojiOneFacade::class,
```

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)
```

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:`

In your view where you display your comments you can use 

```php
@emojione($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:

```bash
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`

PNG files in sizes 32/64/128:

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

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:

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

In `config/emojione.php` enable sprites:

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

Add the stylesheet to your HTML:

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


## License

Remember to read the [EmojiOne Free License](https://www.emojione.com/developers/free-license) and provide the appropriate attribution. Or buy a  [premium license](https://www.emojione.com/developers/premium-license)

[ico-version]: https://img.shields.io/packagist/v/christofferok/laravel-emojione.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/christofferok/laravel-emojione/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/christofferok/laravel-emojione.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/christofferok/laravel-emojione.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/christofferok/laravel-emojione.svg?style=flat-square

[link-packagist]: https://packagist.org/packages/christofferok/laravel-emojione
[link-travis]: https://travis-ci.org/christofferok/laravel-emojione
[link-scrutinizer]: https://scrutinizer-ci.com/g/christofferok/laravel-emojione/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/christofferok/laravel-emojione
[link-downloads]: https://packagist.org/packages/christofferok/laravel-emojione
[link-author]: https://github.com/christofferok


================================================
FILE: composer.json
================================================
{
    "name": "christofferok/laravel-emojione",
    "type": "library",
    "description": "Laravel helper for EmojiOne",
    "keywords": [
        "ChristofferOK",
        "LaravelEmojiOne",
        "laravel",
        "emoji",
        "emojione"
    ],
    "homepage": "https://github.com/christofferok/LaravelEmojiOne",
    "license": "MIT",
    "authors": [
        {
            "name": ":Christoffer Korvald",
            "email": "korvald@gmail.com",
            "homepage": "https://christofferok.com",
            "role": "Developer"
        }
    ],
    "require": {
        "php": "~5.6|~7.0|~8.0",
        "emojione/emojione": "^4.0.0",
        "illuminate/support": "~5.1|~6.0|~7.0|~8.0|~9.0"
    },
    "suggest": {
        "emojione/assets": "If you want to serve the emojione assets yourself"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0|~5.0",
        "squizlabs/php_codesniffer": "^2.3"
    },
    "autoload": {
        "psr-4": {
            "ChristofferOK\\LaravelEmojiOne\\": "src"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "ChristofferOK\\LaravelEmojiOne\\": "tests"
        }
    },
    "scripts": {},
    "extra": {
        "laravel": {
            "providers": [
                "ChristofferOK\\LaravelEmojiOne\\LaravelEmojiOneServiceProvider"
            ],
            "aliases": {
                "LaravelEmojiOne": "ChristofferOK\\LaravelEmojiOne\\LaravelEmojiOneFacade"
            }
        }
    },
    "config": {
        "sort-packages": true
    }
}


================================================
FILE: config/emojione.php
================================================
<?php
return [
    'imagePathPNG' => null, // defaults to jsdelivr's free CDN
    'sprites' => false, // use sprites?
    'spriteSize' => 32, // 32/64

    // If you are using the cdn, then you can change these values to get different sizes
    'emojiSize' => 64, // 32/64/128
    'emojiVersion' => '4.0',
    
    'ascii' => false, // convert ascii characters into emoji shortcodes
];


================================================
FILE: src/LaravelEmojiOne.php
================================================
<?php

namespace ChristofferOK\LaravelEmojiOne;

use Emojione\Client;
use Emojione\Ruleset;

class LaravelEmojiOne
{
    private $client;

    public function __construct()
    {
        $this->client = new Client(new Ruleset());

        $this->client->emojiSize = config('emojione.emojiSize');
        $this->client->sprites = config('emojione.sprites');
        $this->client->spriteSize = config('emojione.spriteSize');
        $this->client->emojiVersion = config('emojione.emojiVersion');

        if (config('emojione.imagePathPNG')) {
            $this->client->imagePathPNG = url(config('emojione.imagePathPNG')) . '/';
        }
        else {
            // Use the CDN if 'imagePathPNG' config is not set
            $this->client->imagePathPNG = 'https://cdn.jsdelivr.net/emojione/assets' . '/' . $this->client->emojiVersion . '/png/' . $this->client->emojiSize . '/';
        }
        
        // config ascii option added ternary incase option isn't part of config 
        $this->client->ascii = config('emojione.ascii') ? true : false;
        
    }

    public function toImage($str)
    {
        return $this->client->toImage($str);
    }

    public function toShort($str)
    {
        return $this->client->toShort($str);
    }

    public function shortnameToImage($str)
    {
        return $this->client->shortnameToImage($str);
    }

    public function unicodeToImage($str)
    {
        return $this->client->unicodeToImage($str);
    }

    public function getClient()
    {
        return $this->client;
    }
}


================================================
FILE: src/LaravelEmojiOneFacade.php
================================================
<?php
namespace ChristofferOK\LaravelEmojiOne;

use Illuminate\Support\Facades\Facade;

class LaravelEmojiOneFacade extends Facade
{
    protected static function getFacadeAccessor()
    {
        return LaravelEmojiOne::class;
    }
}


================================================
FILE: src/LaravelEmojiOneServiceProvider.php
================================================
<?php

namespace ChristofferOK\LaravelEmojiOne;

use Illuminate\Contracts\Container\Container;
use Illuminate\Support\ServiceProvider;

class LaravelEmojiOneServiceProvider extends ServiceProvider
{

    public function boot()
    {
        $this->publishes([__DIR__.'/../config/emojione.php' => config_path('emojione.php')], 'config');

        $this->publishes([
            base_path('vendor/emojione/assets/png') => public_path('vendor/emojione/png'),
        ], 'public');

        $this->publishes([
            base_path('vendor/emojione/assets/sprites') => public_path('vendor/emojione/sprites'),
        ], 'sprites');

        \Blade::directive('emojione', function ($expression) {
            return "<?php echo \App::make('".LaravelEmojiOne::class."')->toImage($expression); ?>";
        });
    }

    public function register()
    {
        $this->mergeConfigFrom(__DIR__.'/../config/emojione.php', 'emojione');
        $this->app->singleton(LaravelEmojiOne::class, function (Container $app) {
            return new LaravelEmojiOne();
        });
    }
}
Download .txt
gitextract_slq4sk2c/

├── .editorconfig
├── .gitignore
├── LICENSE.md
├── README.md
├── composer.json
├── config/
│   └── emojione.php
└── src/
    ├── LaravelEmojiOne.php
    ├── LaravelEmojiOneFacade.php
    └── LaravelEmojiOneServiceProvider.php
Download .txt
SYMBOL INDEX (12 symbols across 3 files)

FILE: src/LaravelEmojiOne.php
  class LaravelEmojiOne (line 8) | class LaravelEmojiOne
    method __construct (line 12) | public function __construct()
    method toImage (line 34) | public function toImage($str)
    method toShort (line 39) | public function toShort($str)
    method shortnameToImage (line 44) | public function shortnameToImage($str)
    method unicodeToImage (line 49) | public function unicodeToImage($str)
    method getClient (line 54) | public function getClient()

FILE: src/LaravelEmojiOneFacade.php
  class LaravelEmojiOneFacade (line 6) | class LaravelEmojiOneFacade extends Facade
    method getFacadeAccessor (line 8) | protected static function getFacadeAccessor()

FILE: src/LaravelEmojiOneServiceProvider.php
  class LaravelEmojiOneServiceProvider (line 8) | class LaravelEmojiOneServiceProvider extends ServiceProvider
    method boot (line 11) | public function boot()
    method register (line 28) | public function register()
Condensed preview — 9 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (14K chars).
[
  {
    "path": ".editorconfig",
    "chars": 312,
    "preview": "; This file is for unifying the coding style for different editors and IDEs.\n; More information at http://editorconfig.o"
  },
  {
    "path": ".gitignore",
    "chars": 46,
    "preview": "/node_modules\n/vendor\ncomposer.lock\n.DS_Store\n"
  },
  {
    "path": "LICENSE.md",
    "chars": 1140,
    "preview": "# The MIT License (MIT)\n\nCopyright (c) 2017 Christoffer Korvald <korvald@gmail.com>\n\n> Permission is hereby granted, fre"
  },
  {
    "path": "README.md",
    "chars": 6464,
    "preview": "# laravel-emojione <img alt=\"❤️\" width=\"30\" src=\"https://cdn.jsdelivr.net/emojione/assets/4.0/png/128/2764.png\">\n\n[![Lat"
  },
  {
    "path": "composer.json",
    "chars": 1527,
    "preview": "{\n    \"name\": \"christofferok/laravel-emojione\",\n    \"type\": \"library\",\n    \"description\": \"Laravel helper for EmojiOne\","
  },
  {
    "path": "config/emojione.php",
    "chars": 386,
    "preview": "<?php\nreturn [\n    'imagePathPNG' => null, // defaults to jsdelivr's free CDN\n    'sprites' => false, // use sprites?\n  "
  },
  {
    "path": "src/LaravelEmojiOne.php",
    "chars": 1546,
    "preview": "<?php\n\nnamespace ChristofferOK\\LaravelEmojiOne;\n\nuse Emojione\\Client;\nuse Emojione\\Ruleset;\n\nclass LaravelEmojiOne\n{\n   "
  },
  {
    "path": "src/LaravelEmojiOneFacade.php",
    "chars": 236,
    "preview": "<?php\nnamespace ChristofferOK\\LaravelEmojiOne;\n\nuse Illuminate\\Support\\Facades\\Facade;\n\nclass LaravelEmojiOneFacade exte"
  },
  {
    "path": "src/LaravelEmojiOneServiceProvider.php",
    "chars": 1071,
    "preview": "<?php\n\nnamespace ChristofferOK\\LaravelEmojiOne;\n\nuse Illuminate\\Contracts\\Container\\Container;\nuse Illuminate\\Support\\Se"
  }
]

About this extraction

This page contains the full source code of the christofferok/laravel-emojione GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 9 files (12.4 KB), approximately 3.6k tokens, and a symbol index with 12 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!