Webservice that exposes two APIs to play to Tic Tac Toe Game.
- install docker
- install docker-compose
- install git
- clone this repository with
git clone [email protected]:elplaza/tictactoe.git <dir>
- move to project
<dir>
withmv <dir>
Run tic tac toe webservice:
docker compose up -d
Check all running containers:
docker compose ps
You should see db
and php
services running.
Exposed API:
- Create a new game session (start game):
- Request POST /public/api/game-sessions
- Response returns a new game session (id, players, board, etc...)
- Update the specific game session (make a move):
- Request PUT /public/api/game-sessions/{id}
- Response returns the game session updated (updated board, player won, etc...)
Call exposed APIs with an http client (cUrl, Postman, Frontend app, etc...) like this:
curl -X POST http://localhost:8073/public/api/game-sessions
curl -X PUT -d '{"player_id":"<Player ID>","row":<Row>,"column":<Column>}' http://localhost:8073/public/api/game-sessions/<GameSession ID>
where:
- Player ID
is the ID of the player that makes the move (players IDS are returned from create game session API)
- Column
is the column number (from 1 to 3)
- Row
is the row number (from 1 to 3)
- GameSession ID
is the ID of the current GameSession (game session ID is returned from create game session API)
Run static code analysis:
docker compose run php psalm
Detect coding standard violations:
docker compose run php cs
Fix coding standard violations:
docker compose run php cbf
Run automatic tests:
docker compose up -d db_test
docker compose run php test