From 6ddcb03fe86ea1cdf6dff3f8030199b783f92fcf Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Mon, 12 Mar 2018 14:47:32 -0400 Subject: [PATCH] Add local development example site. --- .gitignore | 1 + docker-compose.yml | 18 ++++++++++++- docker/nginx/site.conf | 26 +++++++++++++++++++ phpunit.xml.dist | 2 +- public/docs | 1 + public/index.php | 58 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 docker/nginx/site.conf create mode 120000 public/docs create mode 100644 public/index.php diff --git a/.gitignore b/.gitignore index 9c256bd..88bfaac 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ vendor/ phpdoc/ # Code coverage report +coverage/ report/ # Sphinx Documentation diff --git a/docker-compose.yml b/docker-compose.yml index b4ac5c5..767276c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ version: '2' services: + # PHPUnit and Composer php: build: context: . @@ -8,9 +9,24 @@ services: volumes: - .:/usr/local/src/wellrested + # Documentation generator docs: build: context: . dockerfile: ./docker/docs/Dockerfile volumes: - - .:/usr/local/src/wellrested \ No newline at end of file + - .:/usr/local/src/wellrested + + # Local development site + nginx: + image: nginx:1.13 + ports: + - 8080:80 + volumes: + - .:/usr/local/src/wellrested + - ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf + + php-fpm: + image: php:7.1-fpm + volumes: + - .:/usr/local/src/wellrested diff --git a/docker/nginx/site.conf b/docker/nginx/site.conf new file mode 100644 index 0000000..c0def51 --- /dev/null +++ b/docker/nginx/site.conf @@ -0,0 +1,26 @@ +server { + listen 80; + + root /usr/local/src/wellrested/public; + index index.php index.html; + charset utf-8; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Front Controller + location / { + try_files $uri $uri/ /index.php?$args; + } + + # PHP + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass php-fpm:9000; + fastcgi_index index.php; + fastcgi_buffers 8 8k; + fastcgi_buffer_size 16k; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME index.php; + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a5088c5..5ed29fc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -24,6 +24,6 @@ - + diff --git a/public/docs b/public/docs new file mode 120000 index 0000000..0a6ccc9 --- /dev/null +++ b/public/docs @@ -0,0 +1 @@ +../docs/build/html \ No newline at end of file diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..4156ac2 --- /dev/null +++ b/public/index.php @@ -0,0 +1,58 @@ + + + + + WellRESTed Development Site + + +

WellRESTed Development Site

+ +

To run unit tests, run:

+ docker-compose run --rm php phpunit +

View the code coverage report.

+ +

To generate documentation, run:

+ docker-compose run --rm docs +

View documentation.

+ + +HTML; + + return (new Response(200)) + ->withHeader('Content-type', 'text/html') + ->withBody(new Stream($view)); + } +} + +// ----------------------------------------------------------------------------- + +$server = new Server(); + +// Add a router to the server to map methods and endpoints to handlers. +$router = $server->createRouter(); +$router->register("GET", "/", new HomePageHandler()); +$server->add($router); + +// Read the request from the client, dispatch a handler, and output. +$server->respond();