Code Monkey home page Code Monkey logo

user-microservice's Introduction

User microservice

PHP framework

Lumen PHP Framework

Test framework

PHPUnit

Database

Mysql 5.7

Docker Containers

  • web - Web application container (Ubuntu 20.04, php-fpm, nginx, composer)
  • db - MySQL container
  • test-db - MySQL container for testing.

Setup Steps

If docker compose has not been installed, please follow this documentation to install it for your operational system. https://docs.docker.com/compose/install/

  1. Go to the folder you normally set up projects and run git clone [email protected]:yao9394/user-microservice.git
  2. Next, open a new terminal and run
    cd user-microservice/
    
  3. Run
    docker-compose up --build
    
  4. Open another terminal in the same folder and run
    sudo ./setup.sh 
    
  5. Visit http://localhost to see the version of Lumen

User microservice user guide

This application consists of 5 API endpoints

  1. List all users Get http://localhost/user

    • Response
    [
    {
        "id": 1,
        "name": "Mr. Johnson Strosin",
        "email": "[email protected]",
        "created_at": "2021-01-10T14:53:41.000000Z",
        "updated_at": "2021-01-10T14:53:41.000000Z"
    },
    {
        "id": 2,
        "name": "Travon Hartmann",
        "email": "[email protected]",
        "created_at": "2021-01-10T14:53:41.000000Z",
        "updated_at": "2021-01-10T14:53:41.000000Z"
    },
    ]
    
  2. Display a user Get http://localhost/user/1

    • Response
      {
          "id": 1,
          "name": "Mr. Johnson Strosin",
          "email": "[email protected]",
          "created_at": "2021-01-10T14:53:41.000000Z",
          "updated_at": "2021-01-10T14:53:41.000000Z"
      }
      
  3. Add a new user Post http://localhost/user

    • Request
      {
          "name": "test",
          "email": "[email protected]"
      }
      
    • Response
      {
          "name": "test",
          "email": "[email protected]",
          "updated_at": "2021-01-10T15:26:58.000000Z",
          "created_at": "2021-01-10T15:26:58.000000Z",
          "id": 51
      }
      
  4. Update a user Put/Patch http://localhost/user/update/{id}

    • Request (same as Add a new user)
    • Response (same as Add a new user)
  5. Delete a user Delete http://localhost/user/delete/{id}

    • Request (same as Add a new user)
    • Response (same as Add a new user)

Testing

In a terminal, run

docker exec -it user-microservice_web_1 bash

and then

cd siteroot/

next

root@b76b9e1b8e17:/siteroot/siteroot# vendor/bin/phpunit 
PHPUnit 9.5.0 by Sebastian Bergmann and contributors.

......                                                              6 / 6 (100%)

Time: 00:00.712, Memory: 24.00 MB

OK (6 tests, 76 assertions)

user-microservice's People

Contributors

yao9394 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.