-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.php
More file actions
26 lines (20 loc) · 751 Bytes
/
app.php
File metadata and controls
26 lines (20 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
// Start the session
session_start();
// PHP Includes always from Root
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT']);
// Require composer Autoload
require __DIR__ . '/vendor/autoload.php';
// Load setted variables inside .env on $_ENV array
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
// Database Config
if ($_ENV['DB_ON']) {
$mysqli = mysqli_init();
if (!$mysqli->real_connect($_ENV['DB_HOST'], $_ENV['DB_USERNAME'], $_ENV['DB_PASSWORD'], $_ENV['DB_DATABASE'])) {
die('Error trying to connect to the database ' . $mysqli->errno . ': ' . $mysqli->error);
}
$mysqli->set_charset('utf8');
}
// PHP require functions
require_once('functions/functions.php');