Skip to content

programadormarin/tictactoe

Repository files navigation

Tic Tac Toe Game

Codacy Badge Build Status Maintainability Test Coverage

This is a Tic Tac Toe game built in PHP 7 with Symfony 4!

Installation

Requirements

  • PHP 7.2.6
  • Docker Compose (for docker usage)

Clone this repository using HTTPS or SSH

$ git clone [email protected]:programadormarin/tictactoe.git

Install all the backend dependencies using composer

$ composer install

Run

Using Docker Compose

If you don't have PHP running in your local machine, user Docker Compose to build this application.

$ docker-compose up --build -d

Now just go to http://localhost:8000 and enjoy!

Test

To run the tests just access the path of project and run:

$ bin/phpunit

If you are using docker for application and not running PHP on your local machine please run the following commmands:

$ docker-compose exec php ./bin/phpunit

Usage

POST http://localhost:8000/api/move
{
  "playerUnit" : "X",
  "boardState" : 
  	[
      ["X", "O", ""],
      ["X", "O", "O"],
      ["",  "",  ""]
    ]  
  
}

Response 200 OK
{
    "nextMove": [0, 1, 'O'],
    "winner": "X",
    "tied": false
}

Using curl:

curl -X POST \
  http://localhost:8000/api/move \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "playerUnit" : "X",
  "boardState" : 
  	[
      ["X", "O", ""],
      ["X", "O", "O"],
      ["",  "",  ""]
    ]  
  
}'

About

A simple tic tac toe game writed in PHP with symfony 4.1, using docker-compose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •