-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
31 lines (25 loc) · 731 Bytes
/
bootstrap.php
File metadata and controls
31 lines (25 loc) · 731 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
27
28
29
30
31
<?php
require_once __DIR__ . '/vendor/autoload.php';
if (isset($_SERVER['REQUEST_URI'])) {
$path = preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
$filename = __DIR__ . '/public/' . $path;
if (php_sapi_name() === 'cli-server' && is_file($filename)) {
return false;
}
}
$env = isset($_ENV['env']) ? $_ENV['env'] : 'production';
$isTest = $env == 'test';
$path = __DIR__ . '/resources/data/todos.sqlite';
if ($isTest) {
$path = __DIR__ . '/resources/data/todos.test.sqlite';
if (file_exists($path)) {
unlink($path);
}
}
$app = new W5n\Application(
$env,
__DIR__ . '/resources',
$path,
__DIR__ . '/resources/data/db-template.sqlite'
);
return $app;