From 20960419a3b6b4cf92ca8c94d57a63dff9cc5e6c Mon Sep 17 00:00:00 2001
From: Peter Hoppe
Date: Fri, 1 Aug 2025 18:34:16 +0200
Subject: [PATCH] a lot of enviroment stuff added
---
.project | 11 +
composer.json | 3 +-
composer.lock | 400 ++++++++++++++++++++++++++++++-
php/php-dog/.env | 6 +-
php/php-dog/.env.devDocker | 5 +
php/php-dog/.env.development | 5 +
php/php-dog/.env.production | 5 +
php/php-dog/classes/Database.php | 32 ++-
php/php-dog/classes/env.php | 11 +
php/php-dog/tstEnv.php | 18 ++
10 files changed, 469 insertions(+), 27 deletions(-)
create mode 100644 .project
create mode 100644 php/php-dog/.env.devDocker
create mode 100644 php/php-dog/.env.development
create mode 100644 php/php-dog/.env.production
create mode 100644 php/php-dog/classes/env.php
create mode 100644 php/php-dog/tstEnv.php
diff --git a/.project b/.project
new file mode 100644
index 0000000..42d02f9
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+
+
+ dog
+
+
+
+
+
+
+
+
diff --git a/composer.json b/composer.json
index e5dc3ed..1871357 100644
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,8 @@
"phpmailer/phpmailer": "^6.7.1",
"php-http/guzzle7-adapter": "*",
"nyholm/psr7": "*",
- "mailersend/mailersend": "^0.34.0"
+ "mailersend/mailersend": "^0.34.0",
+ "vlucas/phpdotenv": "^5.6"
},
"config": {
"allow-plugins": {
diff --git a/composer.lock b/composer.lock
index 2b4ff48..c3649bc 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "b1e69d7076ff4792cd7496e37cca89f4",
+ "content-hash": "92ada81017bb93ecc3a303b879d79b1c",
"packages": [
{
"name": "beberlei/assert",
@@ -139,6 +139,68 @@
],
"time": "2023-12-20T15:40:13+00:00"
},
+ {
+ "name": "graham-campbell/result-type",
+ "version": "v1.1.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/GrahamCampbell/Result-Type.git",
+ "reference": "3ba905c11371512af9d9bdd27d99b782216b6945"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945",
+ "reference": "3ba905c11371512af9d9bdd27d99b782216b6945",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2.5 || ^8.0",
+ "phpoption/phpoption": "^1.9.3"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "GrahamCampbell\\ResultType\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ }
+ ],
+ "description": "An Implementation Of The Result Type",
+ "keywords": [
+ "Graham Campbell",
+ "GrahamCampbell",
+ "Result Type",
+ "Result-Type",
+ "result"
+ ],
+ "support": {
+ "issues": "https://github.com/GrahamCampbell/Result-Type/issues",
+ "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-07-20T21:45:45+00:00"
+ },
{
"name": "guzzlehttp/guzzle",
"version": "7.9.3",
@@ -995,16 +1057,16 @@
},
{
"name": "phpmailer/phpmailer",
- "version": "v6.7.1",
+ "version": "v6.10.0",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
- "reference": "49cd7ea3d2563f028d7811f06864a53b1f15ff55"
+ "reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/49cd7ea3d2563f028d7811f06864a53b1f15ff55",
- "reference": "49cd7ea3d2563f028d7811f06864a53b1f15ff55",
+ "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
+ "reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
"shasum": ""
},
"require": {
@@ -1014,16 +1076,17 @@
"php": ">=5.5.0"
},
"require-dev": {
- "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
+ "dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"doctrine/annotations": "^1.2.6 || ^1.13.3",
"php-parallel-lint/php-console-highlighter": "^1.0.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpcompatibility/php-compatibility": "^9.3.5",
"roave/security-advisories": "dev-latest",
- "squizlabs/php_codesniffer": "^3.7.1",
+ "squizlabs/php_codesniffer": "^3.7.2",
"yoast/phpunit-polyfills": "^1.0.4"
},
"suggest": {
+ "decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication",
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
"ext-openssl": "Needed for secure SMTP sending and DKIM signing",
"greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication",
@@ -1063,7 +1126,7 @@
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"support": {
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
- "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.7.1"
+ "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.10.0"
},
"funding": [
{
@@ -1071,7 +1134,82 @@
"type": "github"
}
],
- "time": "2022-12-08T13:30:06+00:00"
+ "time": "2025-04-24T15:19:31+00:00"
+ },
+ {
+ "name": "phpoption/phpoption",
+ "version": "1.9.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/schmittjoh/php-option.git",
+ "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54",
+ "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2.5 || ^8.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.2",
+ "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28"
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ },
+ "branch-alias": {
+ "dev-master": "1.9-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "PhpOption\\": "src/PhpOption/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com",
+ "homepage": "https://github.com/schmittjoh"
+ },
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ }
+ ],
+ "description": "Option Type for PHP",
+ "keywords": [
+ "language",
+ "option",
+ "php",
+ "type"
+ ],
+ "support": {
+ "issues": "https://github.com/schmittjoh/php-option/issues",
+ "source": "https://github.com/schmittjoh/php-option/tree/1.9.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-07-20T21:41:07+00:00"
},
{
"name": "psr/http-client",
@@ -1411,6 +1549,166 @@
],
"time": "2025-04-04T13:12:05+00:00"
},
+ {
+ "name": "symfony/polyfill-ctype",
+ "version": "v1.32.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
+ "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2"
+ },
+ "provide": {
+ "ext-ctype": "*"
+ },
+ "suggest": {
+ "ext-ctype": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/polyfill",
+ "name": "symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Gert de Pagter",
+ "email": "BackEndTea@gmail.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for ctype functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "ctype",
+ "polyfill",
+ "portable"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-ctype/tree/v1.32.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-09-09T11:45:10+00:00"
+ },
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.32.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493",
+ "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493",
+ "shasum": ""
+ },
+ "require": {
+ "ext-iconv": "*",
+ "php": ">=7.2"
+ },
+ "provide": {
+ "ext-mbstring": "*"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/polyfill",
+ "name": "symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-12-23T08:48:59+00:00"
+ },
{
"name": "symfony/polyfill-php80",
"version": "v1.32.0",
@@ -1490,6 +1788,90 @@
}
],
"time": "2025-01-02T08:10:11+00:00"
+ },
+ {
+ "name": "vlucas/phpdotenv",
+ "version": "v5.6.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/vlucas/phpdotenv.git",
+ "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/24ac4c74f91ee2c193fa1aaa5c249cb0822809af",
+ "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af",
+ "shasum": ""
+ },
+ "require": {
+ "ext-pcre": "*",
+ "graham-campbell/result-type": "^1.1.3",
+ "php": "^7.2.5 || ^8.0",
+ "phpoption/phpoption": "^1.9.3",
+ "symfony/polyfill-ctype": "^1.24",
+ "symfony/polyfill-mbstring": "^1.24",
+ "symfony/polyfill-php80": "^1.24"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.2",
+ "ext-filter": "*",
+ "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2"
+ },
+ "suggest": {
+ "ext-filter": "Required to use the boolean validator."
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ },
+ "branch-alias": {
+ "dev-master": "5.6-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Dotenv\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Vance Lucas",
+ "email": "vance@vancelucas.com",
+ "homepage": "https://github.com/vlucas"
+ }
+ ],
+ "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
+ "keywords": [
+ "dotenv",
+ "env",
+ "environment"
+ ],
+ "support": {
+ "issues": "https://github.com/vlucas/phpdotenv/issues",
+ "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.2"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2025-04-30T23:37:27+00:00"
}
],
"packages-dev": [],
diff --git a/php/php-dog/.env b/php/php-dog/.env
index 2af1a5f..9ec7e9d 100644
--- a/php/php-dog/.env
+++ b/php/php-dog/.env
@@ -1,5 +1 @@
- DB_HOST=mysql
- DB_NAME=dog
- DB_USER=user_dog
- DB_PW=X0pEiBsXN3RLazGhQVvP
- API_KEY=mlsn.bb01e227d0e4b8a77984cbcc05de7a93d42b356676b964df9ac5a7b93567b13f
+APP_ENV=development
\ No newline at end of file
diff --git a/php/php-dog/.env.devDocker b/php/php-dog/.env.devDocker
new file mode 100644
index 0000000..6cf72b7
--- /dev/null
+++ b/php/php-dog/.env.devDocker
@@ -0,0 +1,5 @@
+ DB_HOST=localhost
+ DB_NAME=dog
+ DB_USER=user_dog
+ DB_PW=X0pEiBsXN3RLazGhQVvP
+ API_KEY=mlsn.bb01e227d0e4b8a77984cbcc05de7a93d42b356676b964df9ac5a7b93567b13f
diff --git a/php/php-dog/.env.development b/php/php-dog/.env.development
new file mode 100644
index 0000000..687d3e6
--- /dev/null
+++ b/php/php-dog/.env.development
@@ -0,0 +1,5 @@
+ DB_HOST=localhost
+ DB_NAME=k200835_dog
+ DB_USER=k200835_user_dog
+ DB_PW=X0pEiBsXN3RLazGhQVvP
+ API_KEY=mlsn.bb01e227d0e4b8a77984cbcc05de7a93d42b356676b964df9ac5a7b93567b13f
diff --git a/php/php-dog/.env.production b/php/php-dog/.env.production
new file mode 100644
index 0000000..2af1a5f
--- /dev/null
+++ b/php/php-dog/.env.production
@@ -0,0 +1,5 @@
+ DB_HOST=mysql
+ DB_NAME=dog
+ DB_USER=user_dog
+ DB_PW=X0pEiBsXN3RLazGhQVvP
+ API_KEY=mlsn.bb01e227d0e4b8a77984cbcc05de7a93d42b356676b964df9ac5a7b93567b13f
diff --git a/php/php-dog/classes/Database.php b/php/php-dog/classes/Database.php
index cf8eacd..092edb7 100644
--- a/php/php-dog/classes/Database.php
+++ b/php/php-dog/classes/Database.php
@@ -1,20 +1,28 @@
load();
+
+$environment = $_ENV['APP_ENV'] ?: 'development'; // Standardmäßig Entwicklung
+
+$dotenv = Dotenv\Dotenv::createImmutable(__DIR__, '.env.' . $environment);
+$dotenv->load();
+?>
diff --git a/php/php-dog/tstEnv.php b/php/php-dog/tstEnv.php
new file mode 100644
index 0000000..7230151
--- /dev/null
+++ b/php/php-dog/tstEnv.php
@@ -0,0 +1,18 @@
+load();
+
+$database_url = $_ENV['DB_HOST'];
+$database_name = $_ENV['DB_NAME'];
+$database_user = $_ENV['DB_USER'];
+$database_password = $_ENV['DB_PW'];
+
+echo "Datenbank-URL: " . $database_url . "
";
+echo "Datenbank-Name: " . $database_name . "
";
+echo "Datenbank-Benutzer: " . $database_user . "
";
+echo "Datenbank-Passwort: " . $database_password . "
";
+?>
\ No newline at end of file