Skip to content

acolono/opencounter_api

Repository files navigation

build status

Table of Contents

OpenCounter Logo

A minimal example for developers to demonstrate

  • REST and API
  • Iteration over incrementation
  • Object oriented
  • Automated software testing (and test driven development)

A simple useful application/service/backend with usecases that lets the user:

  1. Register a counter with a password
  2. Retrieve the counter value
  3. Change the value by incrementing it by 1 (providing the password)

A counter has a:

  • Name which can be changed
  • Unique ID
  • Value
  • Status (locked, disabled, active)

Requirements

You need a webserver, Php7 and a database. Point the webserver to ./public directory.

Usage

Production

Use Composer to install dependencies

If you don't have composer installed on your host but have docker then you can use https://github.com/RobLoach/docker-composer

composer install --no-dev

Environment file

You need to create a .env file containing variables. (See example env.dev)

Create the Database installed via Phinx

bin/phinx migrate -c phinx.php

Development

Install Dependencies

composer install

Setup environment variables

cp env.dev .env

Start Docker containers

docker-compose -f docker-compose.dev.yml up

Setup Database

docker exec -t -i opencounter-slim-codenv-php-fpm php /var/www/opencounter-slim-codenv/bin/phinx migrate -c /var/www/opencounter-slim-codenv/phinx.php

Run Tests with these commands

$ bin/run-tests.sh

Probably you will want to use the continuous testing setup which automatically reruns the tests on filesave with immediate feedback in terminal and browser. For this you will need to run

$ npm install

In case you dont have node/npm on your host but have docker running then you can use https://serversforhackers.com/docker-for-gulp-build-tasks (Sorry, put this together into a repo but couldn't share it yet and neither did the OP, feel free to pass me a link to something like this that is ready to use)

This should allow you to run

$ gulp