This is a playful project in which I tried to develop the tic-tac-toe game by applying some DDD principles. There are certainly various refactoring steps to be applied, some of these indicated by a TODO.
git clone https://github.com/matiux/php-tic-tac-toe.git && cd php-tic-tac-toe
cp docker/docker-compose.override.dist.yml docker/docker-compose.override.yml
./dc up -d
./dc composer install --no-dev
./dc project setup-dev
In the examples below I use jq
to format the output json of cURL calls.
You can ignore it or install it on your operating system.
curl --location --request POST 'localhost:8080/v1/new-game' | jq
The play ID
{
"id": "740f31c2-40bd-457f-bcca-390638bfeb66"
}
curl --location --request GET 'localhost:8080/v1/740f31c2-40bd-457f-bcca-390638bfeb66' | jq
{
"board": [
[
"-",
"-",
"-"
],
[
"-",
"-",
"-"
],
[
"-",
"-",
"-"
]
],
"winning": false,
"play_finished": false,
"winning_combination": []
}
curl --location --request POST 'localhost:8080/v1/move' \
--header 'Content-Type: application/json' \
--data-raw '{
"play_id": "740f31c2-40bd-457f-bcca-390638bfeb66",
"player": "O",
"position": 8
}' | jq
{
"board": [
[
"-",
"-",
"-"
],
[
"-",
"-",
"-"
],
[
"-",
"-",
"O"
]
],
"winning": false,
"play_finished": false,
"winning_combination": []
}