A Restful API using Slim framework v3 for a NaijaEmoji Service that implement JWT access token for Authentication.
Composer installation is required before using this package. To install a composer, try running this command on your terminal.
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin
PHP 5.5+ and Composer are required.
$ composer require laztopaz/emoji-restful-api
$ composer install
After you have installed this package, the next line of action is to consume the Emoji API.
You need set your environment variables to define your database parameters or rename .env.example file in project to .env and change the below to your local configuration.
DRIVER = mysql
HOSTNAME = 127.0.0.1
USERNAME = username
PASSWORD = password
DBNAME = YourDatabase
PORT = port
Finally, boot-up the API service with PHP's Built-in web server:
php -S localhost:8000 -t public
All examples are shown in POSTMAN.
To this point we have several endpoints both the ones that requires authentication and non-athenticated.
- POST /auth/login Logs a user in
- GET /auth/logout Logs a user out
- GET /emojis List all the created emojis.
- GET /emojis/{id} Gets a single emoji
- POST /emojis Create a new emoji
- PUT /emojis/{id} Updates an emoji
- PATCH /emojis/{id} Partially updates an emoji
- DELETE /emojis/{id} Deletes a single emoji
- GET /auth/logout Logs a user out
- POST /emojis Create a new emoji
- PUT /emojis/{id} Updates an emoji
- PATCH /emojis/{id} Partially updates an emoji
- DELETE /emojis/{id} Deletes a single emoji
- POST /auth/login Logs a user in
- GET /emojis List all the created emojis.
- GET /emojis/{id} Gets a single emoji
You can create a user all you have to do is to send a POST request to the API endpoint
For a user to be able to access some endpoints, a login access is required and after a successful login, access token will be generated for the user. The user can now include the token in the header of the incoming POST request to be sent to the API.
To create an Emoji, you will need to send a POST request to the API along side with the token in order to create an Emoji.
To get all emojis, you will need to send a GET request to the API
To get a single emoji, you will also need to a send a GET request and the id of the emoji to be retrieved.
To update multiple fields of an Emoji, you will need to send a PUT request To update a single field of an Emoji, you will need to send a PATCH request and set the form encoding to x-www-form-url-encoded along side with access token as header along side with access token.
To update a single field of an Emoji, you will need to send a PATCH request and set the form encoding to x-www-form-url-encoded along side with access token as header.
To delete an Emoji, you will need to send a DELETE request along side with access token as header.
Run this command on your terminal
$ composer test or phpunit test
To contribute and extend the scope of this package, Please check out CONTRIBUTING file for detailed contribution guidelines.
Emoji RESTful API Package is created and maintained by Temitope Olotin.