diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | index.php | 41 | ||||
| -rw-r--r-- | private/controller/Controller.php | 16 | ||||
| -rw-r--r-- | private/model/Connection.php | 19 | ||||
| -rw-r--r-- | private/view/Result.php | 39 |
5 files changed, 116 insertions, 1 deletions
@@ -6,6 +6,6 @@ The main goal of August Offensive is to enable players to interact with the serv ## Technical Objectives -The web service will provide a RESTful API that is written in PHP 7 and connects to a PostGreSQL database. This connection will be managed behind an abstraction layer using PDO. The service will handle users and their game sessions. +The web service will provide a RESTful API that is written in PHP 7 and connects to a PostGreSQL database. This connection will be managed behind an abstraction layer using PDO. The service will handle users and their game sessions. In addition, all PHP code shall follow PSR-1, PSR-2, PSR-4, and PSR-5 coding standards. It is also recommended to try to write as immutably as possible. The front-end of this project will be written using [Elm](http://elm-lang.org/). Work on the front-end portion will not begin until August Offensive's web API has reached relative stability. The version for target stability is alpha 1.0.0. diff --git a/index.php b/index.php new file mode 100644 index 0000000..3e770fe --- /dev/null +++ b/index.php @@ -0,0 +1,41 @@ +<?php + +namespace AugustOffensive; + +include 'private/view/Result.php'; +include 'private/model/Connection.php'; + +use AugustOffensive\view; +use AugustOffensive\model; + +/** + * Constructive controller and initializer API for the service. + */ +class Api +{ + /** @var \Connection $connection the model database interface */ + private $connection; + + /** @var \Result $view the view interface that outputs result of the query */ + private $view; + + /** + * Initiates database connection and forwards environment to the view. + * + * @return Api + */ + public function __construct () + { + $connection = new model\Connection(); + $view = new view\Result($connection); + + // Provide hook for connecting through controller to justify query + $result = $view->collect(); + + // Leak the data + echo $result; + } +} + +new Api(); + diff --git a/private/controller/Controller.php b/private/controller/Controller.php new file mode 100644 index 0000000..73d0210 --- /dev/null +++ b/private/controller/Controller.php @@ -0,0 +1,16 @@ +<?php + +namespace AugustOffensive\controller; + +include '../model/Connection.php'; + +use AugustOffensive\model; + +/** + * Static controller class for interfacing between the view and the model. + */ +class Controller +{ + // +} + diff --git a/private/model/Connection.php b/private/model/Connection.php new file mode 100644 index 0000000..26632f7 --- /dev/null +++ b/private/model/Connection.php @@ -0,0 +1,19 @@ +<?php + +namespace AugustOffensive\model; + +/** + * Model connection class for connecting to database via PDO. + */ +class Connection +{ + /** + * Initiates connection to PostGreSQL database. + * + * @return Connection + */ + public function __construct () + { + // + } +} diff --git a/private/view/Result.php b/private/view/Result.php new file mode 100644 index 0000000..5241e0c --- /dev/null +++ b/private/view/Result.php @@ -0,0 +1,39 @@ +<?php + +namespace AugustOffensive\view; + +include '../controller/Controller.php'; +include '../model/Connection.php'; + +use AugustOffensive\controller; +use AugustOffensive\model; + +/** + * Outputs the JSON result by communicating with the controller. + */ +class Result +{ + /** + * Prepares the output and environment for the front end of the service. + * + * @param \Connection $connection "needs to know" model exists + * + * @return Result + */ + public function __construct (Connection $connection) + { + header("Content-Type: application/json"); + // + } + + /** + * Communicates with the controller to generate the JSON result. + * + * @return array $result resulting sendback object generated from query. + */ + public function collect () + { + // + return array(); + } +} |
