Ecoji for PHP ๐ฃ๐๐ฆ๐ผ๐๐น๐ฆ๐ฒ๐๐๐โ
Ecoji encodes data as 1024 emojis.
It's like base1024
with an emoji character set. Visit ecoji.io to try Ecoji in your browser., (*1)
rayne/ecoji
is a PHP port of Ecoji with 100% test coverage., (*2)
, (*3)
Contents
Installation
composer require rayne/ecoji
Encoding
use Rayne\Ecoji\Ecoji;
$ecoji = new Ecoji;
$ecoji->encode("Base64 is so 1999, isn\'t there something better?\n");
๐๐ฉ๐ฆ๐๐๐๐ฏ๐๐๐ฝ๐๐๐ฑ๐ฅ๐๐ฑ๐๐ญ๐ฎ๐ต๐ข๐ฅ๐ญ๐ธ๐๐ฒ๐ฆ๐ถ๐ข๐ฅ๐ฎ๐บ๐๐ธ๐ฎ๐ผ๐ฆ๐๐ฅด๐
Decoding
use Rayne\Ecoji\Ecoji;
$ecoji = new Ecoji;
$ecoji->decode('๐๐ฉ๐ฆ๐๐๐๐ฏ๐๐๐ฝ๐๐๐ฑ๐ฅ๐๐ฑ๐๐ญ๐ฎ๐ต๐ข๐ฅ๐ญ๐ธ๐๐ฒ๐ฆ๐ถ๐ข๐ฅ๐ฎ๐บ๐๐ธ๐ฎ๐ผ๐ฆ๐๐ฅด๐');
Base64 is so 1999, isn't there something better?
Streams
use Rayne\Ecoji\Ecoji;
$ecoji = new EcojiStream;
$ecoji->encode($sourceStream, $destinationStream);
$ecoji->decode($sourceStream, $destinationStream);
EcojiStream
doesn't wrap the encoded stream without configuring the wrap length first.
A value of 0
disables wrapping., (*4)
use Rayne\Ecoji\Ecoji;
$ecoji = new EcojiStream;
$ecoji->setWrap(80);
CLI
The CLI encodes and decodes files and streams., (*5)
./bin/ecoji --help
Usage: ecoji [OPTIONS]... [FILE]
Encode or decode data as Unicode emojis. ๐
Options:
-d, --decode Decode data.
-w, --wrap COLS Wrap encoded lines after COLS characters (default 76).
Use 0 to disable line wrapping.
-h, --help Print this message.
-v, --version Print version information.
Installing the Composer package rayne/ecoji
will create a symlink, e.g. vendor/bin/ecoji
., (*6)
Docker
Launch a temporary Ecoji Docker container to utilize the CLI:, (*7)
docker run -it --rm rayne/ecoji --help
Pipe data through a container:, (*8)
echo -n "Ecoji for Docker" | docker run -i --rm rayne/ecoji
๐ฃ๐๐ฆ๐ผ๐๐น๐ฆ๐ฒ๐๐๐ง๐ค๐โโโ
Encode or decode a file by mounting it as volume
or piping its content through a container:, (*9)
docker run -it --rm -v /my/message:/file rayne/ecoji /file
cat /my/message | docker run -i --rm rayne/ecoji
Docker Images
The docker/README.md
explains how to build the application and all optional development images for all supported PHP versions.
Additional convenience scripts run the unit tests with all supported PHP versions., (*10)
Tests
The library registers the test runner as composer script., (*11)
composer test
All units tests can also be run in the development containers specified in the docker
directory., (*12)