- 0.1.0 (26/7/2013)
A sample emoji module for Zend Framework 2
1.😁 Hello World
to 😄 Hello World
2.😁 Hello World
to #1f601# Hello World
(You can save it to MySQL < 5.5)
3.#1f601# Hello World
to 😁 Hello World
4.😁 Hello World
to <span class="emoji emoji1f601"></span> Hello World
5.#1f601# Hello World
to <span class="emoji emoji1f601"></span> Hello World
-
Add this project in your composer.json:
"require": { "atans/emoji-module": "dev-master" }
-
Running this command
$ php composer.phar update
```php
<?php
return array(
'modules' => array(
// ...
'EmojiModule',
),
);
```
-
Call
emojimodule_emoji_service
in a controllerpublic function indexAction() { $emojiService = $this->getServiceLocator()->get('emojimodule_emoji_service'); $text = "\xF0\x9F\x98\x81 Hello World"; $variables = $emojiService->encode($text); // Output: #1f601# Hello World (You can save it to MySQL now) // Variables restore to unified $unified = $emojiService->decode($variables); // Output: \xF0\x9F\x98\x81 Hello World // Variables to Html $variablesToHtml = $emojiService->variablesToHtml($variables); // Output: <span class="emoji emoji1f601"></span> Hello World // Unified to html $unifiedToHtml = $emojiService->unifiedToHtml($unified); // Output: <span class="emoji emoji1f601"></span> Hello World return array( 'unifiedToHtml' => $unifiedToHtml, ); }
-
View
copy
https://raw.github.com/iamcal/php-emoji/master/emoji.css
andhttps://github.com/iamcal/php-emoji/blob/master/emoji.png
to '/public/css/'<?php // application/index/index/index.phtml $this->headLink()->appendStylesheet($this->basePath() . '/public/css/emoji.css'); ?> <?php echo echo $unifiedToHtml ?>
-
View Helper
<?php // application/index/index/index.phtml echo $this->emoji()->unifiedToHtml('😁 Hello World') // Output: <span class="emoji emoji1f601"></span> Hello World ?>