-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
61 lines (47 loc) · 1.34 KB
/
bootstrap.php
File metadata and controls
61 lines (47 loc) · 1.34 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
require_once "vendor/autoload.php";
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMSetup;
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$config = ORMSetup::createAttributeMetadataConfiguration(
paths: array(__DIR__."/src"),
isDevMode: true,
);
// configuring the database connection
$connection = DriverManager::getConnection([
// mysql driver
'dbname' => 'timeoff',
'user' => $_ENV['DB_USERNAME'],
'password' =>$_ENV['DB_PASSWORD'],
'host' => 'localhost',
'driver' => 'pdo_mysql',
], $config);
// obtaining the entity manager
try {
$entityManager = new EntityManager($connection, $config);
} catch (\Doctrine\ORM\Exception\MissingMappingDriverImplementation $e) {
}
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/templates',__DIR__);
$twig = new \Twig\Environment($loader, [
'cache' => '/cache/',
'auto_reload' => true,
]);
function getActions(){
return [
'home' => 'index.php',
'departments' => 'departments.php',
'sectors' => 'sectors.php',
'employees' => 'employee.php',
'timeoff' => 'timeoff.php',
'reports' => 'reports.php',
];
}
function render($template, $data = [])
{
global $twig;
$template = $twig->load($template);
echo $template->render($data);
}