add auto load .env

This commit is contained in:
2026-09-10 13:53:20 +02:00
parent d6cb4078bc
commit 9016fb7baf
13 changed files with 532 additions and 28 deletions
+6 -2
View File
@@ -1,4 +1,8 @@
<?php
include_once './connection.php';
include_once './user.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable($_SERVER['DOCUMENT_ROOT']); // dir containing .env
$dotenv->load();
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/auto/connection.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/auto/user.php';
+4 -4
View File
@@ -1,8 +1,8 @@
<?php
$servername = $_ENV['DB_SERVERNAME'];
$username = $_ENV['DB_USERNAME'];
$password = $_ENV['DB_PASS'];
$dbname = $_ENV['DB_NAME'];
$servername = getenv('DB_HOSTNAME');
$username = getenv('DB_USERNAME');
$password = getenv('DB_PASS');
$dbname = getenv('DB_NAME');
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
-2
View File
@@ -1,6 +1,4 @@
<?php
include_once './connection.php';
function hasPermission(int $userId, string $resourceName, string $actionName): bool
{
+4
View File
@@ -1,5 +1,9 @@
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/auto/auto.php';
$notifications = ["Helo1", "hello2"];
echo json_encode($notifications);