PHPackages                             elchroy/lemogis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. elchroy/lemogis

ActiveLibrary

elchroy/lemogis
===============

19[1 PRs](https://github.com/elchroy/Lemojis/pulls)PHP

Since Apr 18Pushed 10y agoCompare

[ Source](https://github.com/elchroy/Lemojis)[ Packagist](https://packagist.org/packages/elchroy/lemogis)[ RSS](/packages/elchroy-lemogis/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Lemojis
=======

[](#lemojis)

[![Coverage Status](https://camo.githubusercontent.com/7981d39da232016af09537e9321e3c194116eb08bbbb10a8b377f9f3ea3f028a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f616e64656c612d63656c697368612d77696777652f4c656d6f6a69732f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/andela-celisha-wigwe/Lemojis?branch=develop)[![StyleCI](https://camo.githubusercontent.com/10bd217ca49bb555e4377ff4c54298ca4bb4e438cba812532388455e84d0179f/68747470733a2f2f7374796c6563692e696f2f7265706f732f35353135383439342f736869656c64)](https://styleci.io/repos/55158494)[![Build Status](https://camo.githubusercontent.com/8494fe884333c7a8fa8f80db4b6e79bb589b09c1eaa6bb0b88ba76e88d1ef4e2/68747470733a2f2f7472617669732d63692e6f72672f616e64656c612d63656c697368612d77696777652f4c656d6f6a69732e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/andela-celisha-wigwe/Lemojis)

A Simple PHP Naija-Emoji Service.

### Installation

[](#installation)

To run this package, you must have PHP 5.5+ and Composer installed.

First download the package.

```
composer require elchroy/lemojis dev-develop

```

Install Composer.

```
$ composer install

```

To use the appplication you have to setup a host and database where to fetch the emojis from.

- Create a file named `config.ini` in root directory of you application.
- The package uses Laravel's `Illuminate/Database` package. Ensure your config file has `collation` and `charset` like so:

```
driver      = mysql
database    = naija
host        = localhost
username    = root
password    =
charset     = utf8
collation   = utf8_unicode_ci
prefix      =
```

### Usage

[](#usage)

Create an `index.php` file, preferrable from the root of your application and run your server.

```
// index.php

// Require the autoload the vendor folder.
require_once 'vendor/autoload.php';

// Make a new instance of the application.
$app = new Elchroy\Lemojis\LemojisApp();

// Run the application.
$app->run();
```

You can run the server using PHP from terminal like so:

```
php -S localhost:8000

PHP 7.0.2 Development Server started at Fri Apr 15 11:59:42 2016
Listening on http://localhost:8000
Document root is /Users/user/Code/CP3/Lemojis/public
Press Ctrl-C to quit.

```

- To Illustrate the usage of this package I will use `curl` to handle http request.
- Note that you can use tools like Postman or DHC.

#### The Home route

[](#the-home-route)

From the terminal, run the following `curl` command.

```
curl -i -X GET -H 'Content-Type: application/json' http://localhost:8000/

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: text/html; charset=UTF-8
Content-Length: 49

Welcome to Lemoji - A Simple Naija Emoji Service.

```

#### Get all emojis

[](#get-all-emojis)

```
curl -i -X GET -H 'Content-Type: application/json' http://localhost:8000/emojis

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 378

{"message":"OK","data":[{"id":1,"name":"smile","chars":"s","keywords":"smile","category":"expressions","date_created":"2016-03-12 17:04:18","date_modified":"2016-03-12 17:04:30","created_by":"roy"},{"id":2,"name":"smiley","chars":"sly","keywords":"smilely","category":"expressions","date_created":"2016-02-12 17:04:20","date_modified":"2016-02-12 17:05:18","created_by":"roy"}]}

```

#### Get one emoji given the ID

[](#get-one-emoji-given-the-id)

```
curl -i -X GET -H 'Content-Type: application/json' http://localhost:8000/emojis/2

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 202

{"message":"OK","data":{"id":2,"name":"smiley","chars":"sly","keywords":"smilely","category":"expressions","date_created":"2016-02-12 17:04:20","date_modified":"2016-02-12 17:05:18","created_by":"roy"}}

```

#### Get an unavailable emoji

[](#get-an-unavailable-emoji)

There is a `404` response when the emoji is not found, or when there is no emoji in the database table.

```
curl -i -X GET -H 'Content-Type: application/json' http://localhost:8000/emojis/200

```

Response:

```
HTTP/1.1 404 Not Found
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 47

{"message":"Cannot find the emoji","data":null}

```

#### Register as a user

[](#register-as-a-user)

To register and use this API use only need a username and a password.

```
curl -i -X POST -H 'Content-Type: application/json' -d '{"username" : "elchroy", "password" : "yorhcle"}' http://localhost:8000/auth/register

```

Response:

```
HTTP/1.1 201 Created
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 65

{"message":"New user has been created successfully.","data":null}

```

#### Login

[](#login)

To login and use this API use need the username and password used to register. If the login details are valid, you will be issued a token.

```
curl -i -X POST -H 'Content-Type: application/json' -d '{"username" : "elchroy", "password" : "yorhcle"}' http://localhost:8000/auth/login

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 279

{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjIwNjgsImp0aSI6Ik1UUTJNRGN5TWpBMk9BPT0iLCJuYmYiOjE0NjA3MjIwNzgsImV4cCI6MTQ2MDcyNDA3OCwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.cNyDaqIITjdFgoS5axWbVOy5lwUJrP9KKN1RZ8H2XP4cQfSofcj1yUDLJRqUCS3GZo16rmn3Fs7uoUdqbd55Nw"}

```

#### Login failure

[](#login-failure)

When the username or password provided are not valid, login is unsuccessful.

```
curl -i -X POST -H 'Content-Type: application/json' -d '{"username" : "elchroy", "password" : "incorrectpassword"}' http://localhost:8000/auth/login

```

Response:

```
HTTP/1.1 404 Not Found
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 56

{"message":"Incorrect username or password","data":null}

```

Only authorized users (users with a token) have access to make request to `create` an emoji, `update` an emoji or `delete` an emoji.

#### Create an emoji

[](#create-an-emoji)

```
curl -i -X POST -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjYzNzIsImp0aSI6Ik1UUTJNRGN5TmpNM01nPT0iLCJuYmYiOjE0NjA3MjYzODIsImV4cCI6MTQ2MDcyODM4MiwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.z22I-1QZwolyVKxE7UwoBUx0UmUJ4qd-ueRMPgNA50WhDCUHGYLFa1Kfw7mQss2SUJoGE5LPAKj_Kk6fkKvMdw' -d '{"name" : "Aunty!", "chars" : "o", "keywords" : "raise hands woman girl", "category" : "people"}' http://localhost:8000/emojis

```

Response:

```
HTTP/1.1 201 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 57

{"message":"The new emoji has been created successfully.","data":null}

```

#### Update an emoji

[](#update-an-emoji)

This is the case where you want to update all the attributes of an emoji.

```
curl -i -X PUT -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjYzNzIsImp0aSI6Ik1UUTJNRGN5TmpNM01nPT0iLCJuYmYiOjE0NjA3MjYzODIsImV4cCI6MTQ2MDcyODM4MiwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.z22I-1QZwolyVKxE7UwoBUx0UmUJ4qd-ueRMPgNA50WhDCUHGYLFa1Kfw7mQss2SUJoGE5LPAKj_Kk6fkKvMdw' -d '{"name" : "Aunties!", "chars" : "Au", "keywords" : "praise pretty women ladies", "category" : "people"}' http://localhost:8000/emojis/2

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 57

{"message":"The emoji has been updated successfully.","data":null}

```

#### Update an emoji (partially)

[](#update-an-emoji-partially)

This is the case where you want to update only some attributes of an emoji.

```
curl -i -X PATCH -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjYzNzIsImp0aSI6Ik1UUTJNRGN5TmpNM01nPT0iLCJuYmYiOjE0NjA3MjYzODIsImV4cCI6MTQ2MDcyODM4MiwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.z22I-1QZwolyVKxE7UwoBUx0UmUJ4qd-ueRMPgNA50WhDCUHGYLFa1Kfw7mQss2SUJoGE5LPAKj_Kk6fkKvMdw' -d '{"name" : "Aunties!", "chars" : "Au"}' http://localhost:8000/emojis/2

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 57

{"message":"The emoji has been updated successfully.","data":null}

```

#### Delete an emoji

[](#delete-an-emoji)

```
curl -i -X DELETE -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjYzNzIsImp0aSI6Ik1UUTJNRGN5TmpNM01nPT0iLCJuYmYiOjE0NjA3MjYzODIsImV4cCI6MTQ2MDcyODM4MiwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.z22I-1QZwolyVKxE7UwoBUx0UmUJ4qd-ueRMPgNA50WhDCUHGYLFa1Kfw7mQss2SUJoGE5LPAKj_Kk6fkKvMdw' http://localhost:8000/emojis/2

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 53

{"message":"The emoji has been deleted.","data":null}

```

#### Update/Delete - When the emoji cannot be found

[](#updatedelete---when-the-emoji-cannot-be-found)

For a request that is needed to create or delete an emoji that cannot be found, a `404` response is returned to the user.

```
curl -i -X DELETE -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjYzNzIsImp0aSI6Ik1UUTJNRGN5TmpNM01nPT0iLCJuYmYiOjE0NjA3MjYzODIsImV4cCI6MTQ2MDcyODM4MiwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.z22I-1QZwolyVKxE7UwoBUx0UmUJ4qd-ueRMPgNA50WhDCUHGYLFa1Kfw7mQss2SUJoGE5LPAKj_Kk6fkKvMdw' http://localhost:8000/emojis/30000

```

Response:

```
HTTP/1.1 404 Not Found
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 53

{"message":"Cannot find the emoji to update.","data":null}

```

#### Unauthorized access to private routes

[](#unauthorized-access-to-private-routes)

Any request to a private route (CREATE, DELETE, UPDATE), with out appropriate validation in the token will return a response to the user.

*For a case where there is not token provided in the request header.*

```
curl -i -X DELETE -H 'Content-Type: application/json' http://localhost:8000/emojis/2

```

Response:

```
HTTP/1.1 400 Bad Request
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 80

{"message":"Bad Request - Token not found in request. Please Login","data":null}

```

*For a case where the token in the header is expired.*

```
curl -i -X DELETE -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjYzNzIsImp0aSI6Ik1UUTJNRGN5TmpNM01nPT0iLCJuYmYiOjE0NjA3MjYzODIsImV4cCI6MTQ2MDcyODM4MiwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.z22I-1QZwolyVKxE7UwoBUx0UmUJ4qd-ueRMPgNA50WhDCUHGYLFa1Kfw7mQss2SUJoGE5LPAKj_Kk6fkKvMdw' http://localhost:8000/emojis/2

```

Response:

```
HTTP/1.1 405 Method Not Allowed
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 80

{"message":"Token is Expired. Please re-login.","data":null}

```

#### Logout

[](#logout)

Only users that have already logged in can logout.

```
curl -i -X GET -H 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE0NjA3MjYzNzIsImp0aSI6Ik1UUTJNRGN5TmpNM01nPT0iLCJuYmYiOjE0NjA3MjYzODIsImV4cCI6MTQ2MDcyODM4MiwiZGF0YSI6eyJ1c2VybmFtZSI6ImVsY2hyb3kifX0.z22I-1QZwolyVKxE7UwoBUx0UmUJ4qd-ueRMPgNA50WhDCUHGYLFa1Kfw7mQss2SUJoGE5LPAKj_Kk6fkKvMdw' http://localhost:8000/auth/logout

```

Response:

```
HTTP/1.1 200 OK
Host: localhost:8000
Connection: close
X-Powered-By: PHP/7.0.2
Content-Type: application/json;charset=utf-8
Content-Length: 49

{"message":"Successfully Logged Out","data":null}

```

### Test

[](#test)

To test this package, you can use [PHPUnit](https://phpunit.de/), from command line (WindowsOS) or terminal(MacOS).

**Note: Ensure to `cd` to root directory of the application.**

`$ phpunit`

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bce467b2e9ccb6932b24e5a481d764821e3f8758997bd37a4a88351ebeba3abc?d=identicon)[elchroy](/maintainers/elchroy)

---

Top Contributors

[![elchroy](https://avatars.githubusercontent.com/u/17028608?v=4)](https://github.com/elchroy "elchroy (26 commits)")

### Embed Badge

![Health badge](/badges/elchroy-lemogis/health.svg)

```
[![Health](https://phpackages.com/badges/elchroy-lemogis/health.svg)](https://phpackages.com/packages/elchroy-lemogis)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
