Giter VIP home page Giter VIP logo

router's Introduction

RbMowatt Router

A PHP router with tests, working example and easy Docker setup.

Directories

  • src - hold the actual code applicable to router functionality
  • tests - where the tests reside
  • docker - the files to build our dockr container and add local code as volume
  • example - implementation of simple example

Usage

  • Register new route < nesting based on . delimitation >
    • Router::resource('patients');
      • will create a series of single level routes
        • /patients
        • patients/1
    • Router::resource('patients.metrics');
      • will create a series of nested routes
        • /patients/1/metrics
        • /patients/1/metrics/2
    • Each route will call a CRUD level method based on Request_Method
      • GET with no args = get()
      • GET with args = index(id)
      • PUT/PATCH = update(id, body)
      • POST = create(body)
      • DELETE = delete(id)
    • In the case of Nested Routes the arguments passed to each method will equal the number of variables in the url
      • Example GET /patients/1/metrics/2
        • results in get(id_1, id_2)
      • Example POST /patients/1/metrics/
        • results in create(id_1, body)
    • POST and PATCH always receive the body params array as the last parameter
      • Normally I'd send it as first param but am doing it this way to match the signatures request in the test

Docker Setup

  • install docker-compose
  • browse to /docker directory
  • run docker-compose up -d
  • connect docker exec -it docker_app_1 /bin/bash
  • from /var/www in container
    • composer install

Test In Postman

  • install Postman
  • edit file postman_collection.json
    • Make sure proper host is listed on line 327
      • This may already be correct if using a *nix based system
  • Import postman_collection.json into Postman
  • Run Requests/Queries

Run Unit Tests

  • from root of repo
    • ./vendor/bin/phpunit

router's People

Contributors

rbmowatt avatar

Stargazers

 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.