working database

This commit is contained in:
Ludvík Prokopec 2022-09-02 15:34:29 +02:00
parent 025f220809
commit 1ca64e40ae
5 changed files with 3 additions and 58 deletions

View File

@ -1,6 +1,6 @@
PRODUCTION=false PRODUCTION=false
DB_HOST="hz-mysql6" DB_HOST="db.db030.webglobe.com"
DB_USER="mysql85033" DB_USER="mysql85033"
DB_PASSWORD="troglodyt" DB_PASSWORD="troglodyt"
DB_DATABASE="mysql122279" DB_DATABASE="mysql122279"

View File

@ -18,8 +18,6 @@ function env($key) {
$router = new \Bramus\Router\Router(); $router = new \Bramus\Router\Router();
$conn = new mysqli(env("DB_HOST"), env("DB_USER"), env("DB_PASSWORD"), env("DB_DATABASE"));
/*
$database = new Medoo([ $database = new Medoo([
'type' => 'mysql', 'type' => 'mysql',
'host' => env("DB_HOST"), 'host' => env("DB_HOST"),
@ -27,7 +25,7 @@ $database = new Medoo([
'username' => env("DB_USER"), 'username' => env("DB_USER"),
'password' => env("DB_PASSWORD") 'password' => env("DB_PASSWORD")
]); ]);
*/
$data = json_decode(file_get_contents("php://input"), true); $data = json_decode(file_get_contents("php://input"), true);
$routesDirectory = __DIR__ . "/routes"; $routesDirectory = __DIR__ . "/routes";

View File

@ -3,6 +3,7 @@
return [ return [
"get" => function($data, $headers, $db) { "get" => function($data, $headers, $db) {
var_dump($db);
return [ return [
"message" => "hello api" "message" => "hello api"
]; ];

View File

@ -1,39 +0,0 @@
#database configuration
#database host
DB_HOST="localhost"
#database user
DB_USER="root"
#database user password
DB_PASS=""
#database name
DB_NAME="test"
#database port
DB_PORT="mysql"
#should connect to database? (false if you don't want to use database)
DB_ENABLED=false
#production flag (true if you want to use production settings)
PRODUCTION=false
#error reporting (true if you want to report errors)
ERROR_REPORTING=true
#character set for whole application
CHARSET="utf-8"
#should force redirect to https? (true if you want to use https)
FORCE_HTTPS=false
#jwt token authentication
#jwt key for token authentication
#online secure passwords generator - https://www.grc.com/passwords.htm
#generate key by PHP - $jwtKey = bin2hex(random_bytes(32));
JWT_KEY=""
#encryption algorithm for jwt token
JWT_ALGO="HS256"
#jwt token server name
SERVER_NAME="http://localhost"
#jwt token expiration time in seconds
JWT_EXPIRATION_TIME=3600

View File

@ -1,18 +1,3 @@
<?php <?php
require_once(__DIR__ . '/vendor/autoload.php');
$envFile = Dotenv\Dotenv::createArrayBacked(__DIR__)->load();
function env($key, $default = null) {
global $envFile;
if(isset($envFile[$key])) {
return $envFile[$key];
}
return $default;
}
header('Content-Type: text/html; charset=' . env("CHARSET"));
require_once(__DIR__ . '/index.html'); require_once(__DIR__ . '/index.html');