Coding challenge - Create a game
Link to the test specification
First, you will need to install the application environment with docker-compose
Go to "How to install the project environment"
Then you will need to enter into videoslots-php-fpm container to run the command to play the game.
Enter into your Linux console and run:
$ docker exec -it videoslots-php-fpm /bin/bash
In the container you can run the command to play the game:
$ php artisan videoslots:game
You will see a json response with the result of the game played.
Examples:
{"board":["monkey","dog","10","9","bird","cat","monkey","monkey","10","bird","9","Q","monkey","bird","Q"],"paylines":[{"0 4 8 10 12":3}],"bet_amount":100,"total_win":20}
{"board":["9","bird","J","monkey","Q","monkey","Q","bird","10","cat","monkey","Q","K","Q","Q"],"paylines":[],"bet_amount":100,"total_win":0}
To validate the code for consistency with a coding standard, go to the project folder and run the commands:
PSR-1
$ vendor/bin/phpcs --standard=PSR1 --extensions=php --ignore=*/database/*,*/resources/*,*/storage/*,*/vendor/*,*/public/index.php,*/tests/bootstrap.php,*/bootstrap/cache/* .
PSR-2
$ vendor/bin/phpcs --standard=PSR2 --extensions=php --ignore=*/database/*,*/resources/*,*/storage/*,*/vendor/*,*/public/index.php,*/tests/bootstrap.php,*/bootstrap/cache/* .
PSR-12
$ vendor/bin/phpcs --standard=PSR12 --extensions=php --ignore=*/database/*,*/resources/*,*/storage/*,*/vendor/*,*/public/index.php,*/tests/bootstrap.php,*/bootstrap/cache/* .
- docker version >17.05.0-ce
- docker-compose version >1.19.0
- git version >2.7.4
To know your docker version run:
$ docker -v
To know your docker-composer version run:
$ docker-compose -v
To know your git version run:
$ git --version
To install the environment, follow the steps below:
Open your Linux console and enter into the workspace you want to clone the project.
Now you need to clone the project:
$ git clone https://github.com/felipedecampos/videoslots-coding-challenge.git
Then you need to enter into the project folder videoslots-coding-challenge:
$ cd videoslots-coding-challenge
Now you need to create the .env file:
$ cp .env.example .env
Note: Please, make sure you are not using the same IP and PORT (PHP and NGINX) mentioned into the .env file # Docker block
If you are already using the IP or PORT, please, replace for another one.
The next thing you should do is set your application key to a random string. Typically, this string should be 32 characters long. The key can be set in the .env file.
After that, you will install the environment with docker-compose:
Note: Please, make sure you have docker and docker-compose already installed in your computer
$ docker-compose up -d
When the containers are already running, you will need to install composer:
$ docker exec videoslots-php-fpm /bin/bash -c "composer install"