From 5c49997eba981cd400872409324dd80c92c247a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Thu, 25 Mar 2021 21:48:25 +0100 Subject: [PATCH] Grundlegender Aufbau erstellt. --- .gitignore | 10 +++++- api/Dockerfile | 5 +++ api/composer.json | 39 +++++++++++++++++++++ api/html/.htaccess | 20 +++++++++++ api/html/index.php | 12 +++++++ api/src/Controller/HelloWorldController.php | 22 ++++++++++++ compose.yml | 13 +++++++ 7 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 api/Dockerfile create mode 100644 api/composer.json create mode 100644 api/html/.htaccess create mode 100644 api/html/index.php create mode 100644 api/src/Controller/HelloWorldController.php create mode 100644 compose.yml diff --git a/.gitignore b/.gitignore index 3c9663e..c8deedb 100644 --- a/.gitignore +++ b/.gitignore @@ -78,7 +78,8 @@ fabric.properties .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* @@ -99,3 +100,10 @@ Network Trash Folder Temporary Items .apdisk +/api/composer.lock +/api/codeception.yml +/api/vendor/ +/api/tests/_* +/api/tests/acceptance +/api/tests/functional +/api/tests/*.suite.yml diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..8707838 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,5 @@ +FROM php:8.0-apache + +WORKDIR /var/www + +RUN a2enmod rewrite \ No newline at end of file diff --git a/api/composer.json b/api/composer.json new file mode 100644 index 0000000..bb74da7 --- /dev/null +++ b/api/composer.json @@ -0,0 +1,39 @@ +{ + "name": "torsten-hettstedt/timekeeping-api", + "description": "REST-Api zum F\u00fcllen einer Tabelle f\u00fcr die Arbeitszeiterfassung.", + "keywords": [ + "microframework", + "rest", + "router", + "psr7" + ], + "license": "GPL-2.0-or-later", + "authors": [ + { + "name": "Torsten Lücke", + "email": "arbeit@torsten-hettstedt.de", + "homepage": "http://torsten-hettstedt.de/" + } + ], + "require": { + "slim/slim": "^4.7.1", + "vlucas/phpdotenv": "^4.2", + "slim/psr7": "^1.3" + }, + "require-dev": { + "phpstan/phpstan": "^0.12.80", + "codeception/codeception": "^4.1.18", + "codeception/module-phpbrowser": "^1.0.0", + "codeception/module-asserts": "^1.0.0" + }, + "autoload": { + "psr-4": { + "TorstenHettstedt\\TimekeepingApi\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "TorstenHettstedt\\TimekeepingApi\\Tests\\Unit\\": "tests/unit" + } + } +} diff --git a/api/html/.htaccess b/api/html/.htaccess new file mode 100644 index 0000000..1125c75 --- /dev/null +++ b/api/html/.htaccess @@ -0,0 +1,20 @@ + + RewriteEngine On + + # Some hosts may require you to use the `RewriteBase` directive. + # 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 index.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. + RewriteRule ^(.*) - [E=BASE:%1] + + # If the above doesn't work you might need to set the `RewriteBase` directive manually, it should be the + # absolute physical path to the directory that contains this htaccess file. + # RewriteBase / + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [QSA,L] + \ No newline at end of file diff --git a/api/html/index.php b/api/html/index.php new file mode 100644 index 0000000..15cac14 --- /dev/null +++ b/api/html/index.php @@ -0,0 +1,12 @@ +get('/', 'TorstenHettstedt\TimekeepingApi\Controller\HelloWorldController:read'); + +$app->addErrorMiddleware(true, true, true); + +$app->run(); \ No newline at end of file diff --git a/api/src/Controller/HelloWorldController.php b/api/src/Controller/HelloWorldController.php new file mode 100644 index 0000000..25cd199 --- /dev/null +++ b/api/src/Controller/HelloWorldController.php @@ -0,0 +1,22 @@ +getBody()->write($payload); + + return $response + ->withHeader('Content-Type', 'application/json') + ->withStatus(200); + } +} \ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..d3ba3ba --- /dev/null +++ b/compose.yml @@ -0,0 +1,13 @@ +volumes: + logs: + driver: local +services: + api: + build: ./api/ + environment: + docker: "true" + ports: + - 8090:80 + volumes: + - ./api:/var/www + - logs:/var/www/logs \ No newline at end of file