battleship-game-api

API for https://github.com/eugene-matvejev/battleship-game-gui

NO ACTIVE CONTRIBUTIONS: I GOT EMPLOYED AS TECH. LEAD, SO I SPEND MOST OF MY TIME ON COMPANY NEEDS

master heroku < authorization prototype >
TDD tests
< Circle CI > PHPUnit build build build
BDD tests
< Circle CI > Behat build build build
< Circle CI > Kahlan build build build
Coverage
codecov.io coverage coverage coverage

other CI engines reports [on master]

scrutinizer-code-quality scrutinizer-code-coverage code-climate-code-quality travis-build-status-master sensio-insight-framework codeship-build-status-master

DEMO : https://battleship-game-api.herokuapp.com/ [API]

Battleship Game API

THIS IS SPARE TIME PROJECT, WORK IN PROGRESS! HIGHLY EXPERIMENTAL!!!

project purpose:

  • try out:
    • cutting edge technologies such as PHP7, SF3, Doctrine2
    • modern approaches such as Test Automation, Continuous Integration|Deployment
  • simulate database loading [~500 transactions per request]
  • deliver preview about my technical knowledge before the job interview

game cheat-code:

  • AI players have only one ship[single-cell] which is located at B2 cell [purpose: easier manual testing]
    • if you will hit B2 cell - you will win

software requirements

  • supported database engines:
    • MySQL >= 5.5
    • MariaDB >= 9.0
    • PostgreSQL >= 9.3
    • SQLite >= 3
  • WIP:
    • MongoDB
  • http server: apache/nginx with PHP7
  • Composer >= 1.0.3

technology stack

key technologies:

used patterns:

  • Front Controller
  • MVC
  • ORM
  • Data Mapper
  • Builder
  • Strategy
  • Factory
  • Singleton
  • Delegation
  • Registry
  • Service Locator
  • Event Dispatcher
  • Dependency Injection

PHP-FIG:

workflow

  • new functionality merged into master branch only via pull requests
  • each pull request have callback to trigger CI engines such as Travis, Circle, CodeShip, Scrutinizer, Sensiolabs Insight, CodeCov
  • result of each pull request is ready-to-use release - using Continuous Delivery principles

gitflow

  • master branch: stable source code, contains release-ready source
  • heroku branch: reflects current deployed app at heroku [Continuous Deployment]
  • _prototype*__ branch: contains new idea [pull request of prototype branch is always next major version release]
  • pull requests follows semantic vesion

how to install

  • $ composer install # to fetches dependencies, executes mandatory deployment commands
    • NOTE: composer is configured to generate parameters.yml using incenteev/composer-parameter-handler
    • NOTE: composer is configured to create database [if not exists] and apply migrations; using prod. env.
  • optional: $ composer dump-autoload --optimize # to generate class-map autoloader
  • optional: $ php bin/console assets:install # to dump assets as hard copies
    • NOTE: by default assets are installed as symlinks

how to execute tests

  • $ php bin/phpunit -c .
  • $ php bin/behat --strict
  • $ php bin/kahlan
    • NOTE: database_name_test in parameters.yml reflects database name for test env.
    • NOTE: test database is wiped and seeded before tests execution

/etc/hosts

127.0.0.1       api.game.local
::1             api.game.local

apache virtual host config:

<VirtualHost 127.0.0.1:80 ::1:80>
    DocumentRoot "%PROJECT_ROOT_DIRECTORY%/web"
    ErrorLog "%PROJECT_ROOT_DIRECTORY%/var/logs/apache_log"

    ServerName api.game.local
    ServerAlias api.game.local
    <Directory "%PROJECT_ROOT_DIRECTORY%/web">
        AllowOverride All
        Order Allow,Deny
        Allow from All

        Require all granted

        # Use the front controller as index file. It serves as a fallback solution when
        # every other rewrite/redirect fails (e.g. in an aliased environment without
        # mod_rewrite). Additionally, this reduces the matching process for the
        # start page (path "/") because otherwise Apache will apply the rewriting rules
        # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
        DirectoryIndex app.php

        # Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
        # to the front controller "/app.php" but be rewritten to "/app.php/app".
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>

        <IfModule mod_rewrite.c>
            RewriteEngine On

            # CORS support
            RewriteCond %{REQUEST_METHOD} OPTIONS
            RewriteRule ^(.*)$ $1 [R=200,L]
            Header always set Access-Control-Allow-Origin "*"
            Header always set Access-Control-Allow-Methods "POST, GET, PATCH"

            # Determine the RewriteBase automatically and set it as environment variable.
            # If you are using Apache aliases to do mass virtual hosting or installed the
            # project in a subdirectory, the base path will be prepended to allow proper
            # resolution of the app.php file and to redirect to the correct URI. It will
            # work in environments without path prefix as well, providing a safe, one-size
            # fits all solution. But as you do not need it in this case, you can comment
            # the following 2 lines to eliminate the overhead.
            RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
            RewriteRule ^(.*) - [E=BASE:%1]

            # Sets the HTTP_AUTHORIZATION header removed by Apache
            RewriteCond %{HTTP:Authorization} .
            RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

            # Redirect to URI without front controller to prevent duplicate content
            # (with and without `/app.php`). Only do this redirect on the initial
            # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
            # endless redirect loop (request -> rewrite to front controller ->
            # redirect -> request -> ...).
            # So in case you get a "too many redirects" error or you always get redirected
            # to the start page because your Apache does not expose the REDIRECT_STATUS
            # environment variable, you have 2 choices:
            # - disable this feature by commenting the following 2 lines or
            # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
            #   following RewriteCond (best solution)
            RewriteCond %{ENV:REDIRECT_STATUS} ^$
            RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

            # If the requested filename exists, simply serve it.
            # We only want to let Apache serve files and not directories.
            RewriteCond %{REQUEST_FILENAME} -f
            RewriteRule ^ - [L]

            # Rewrite all other queries to the front controller.
            RewriteRule ^ %{ENV:BASE}/app.php [L]
        </IfModule>

        <IfModule !mod_rewrite.c>
            <IfModule mod_alias.c>
                # When mod_rewrite is not available, we instruct a temporary redirect of
                # the start page to the front controller explicitly so that the website
                # and the generated links can still be used.
                RedirectMatch 302 ^/$ /app.php/
                # RedirectTemp cannot be used instead
            </IfModule>
        </IfModule>
    </Directory>
</VirtualHost>

Related Repositories

awesome-elixir

awesome-elixir

A curated list of amazingly awesome Elixir and Erlang libraries, resources and s ...

1000_Projects

1000_Projects

:sunglasses: Mega List of practical projects that one can solve in any programm ...

alexa-skills-list

alexa-skills-list

A complete list of all available Alexa Skills ...

Projects

Projects

[Python] Trying to complete all projects from http://www.dreamincode.net/forums/ ...

epic

epic

React example project, that takes you from fun development to high quality produ ...


Top Contributors

eugene-matvejev scrutinizer-auto-fixer