Skip to content

agungprsty/simple-api-with-lumen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6a99a5d · Aug 21, 2022

History

12 Commits
Aug 21, 2022
Aug 19, 2022
Aug 20, 2022
Aug 21, 2022
Aug 19, 2022
Aug 19, 2022
Aug 19, 2022
Aug 21, 2022
Aug 19, 2022
Aug 19, 2022
Aug 19, 2022
Aug 20, 2022
Aug 19, 2022
Aug 19, 2022
Aug 19, 2022
Aug 21, 2022
Aug 21, 2022
Aug 19, 2022
Aug 21, 2022
Aug 19, 2022
Aug 20, 2022
Aug 19, 2022
Aug 19, 2022

Repository files navigation

API with Lumen Framework

slim-api

Introduction

Build a simple API with Lumen Framework. This application already implementation JWT for authorization and UUID identifier ID.

Requirement

  • PHP ^8.0
  • Lumen ^9.0
  • MySql 8.0

Usage

  • click use this template
  • composer install
  • copy .env.example to .env
  • set APP_KEY execute command :
php artisan key:generate
  • set env variable :
DB_DATABASE=<your database>
DB_USERNAME=<your username>
DB_PASSWORD=<your password>

  • set config file:
auth.php.example -> auth.php
jwt.php.example -> jwt.php
logging.php.example -> logging.php
  • set configuration as your needs
  • for JWT_SECRET section by run :
php artisan jwt:secret

Dummy Data

php artisan migrate --seed

Running service

php -S lumen:8000 -t public

Usage service

  • open postman or insomnia
  • create new request authentication
- add name Login, 
- method POST
- url http://localhost:8080/api/auth/login
- add header 
  - Content-Type = application/json
- add body json 
  {
	"email": "[email protected]",
	"password": "12345678"
  }
  • create new request profile
- add name Me, 
- method GET
- url http://localhost:8080/api/profile/me
- add header 
  - Content-Type = application/json
  - Authorization = bearer {ACCESS_TOKEN}
  • Next do the same thing as request profile for post and todo service.