forked from Kdyby/Boilerplate
/
bootstrap.php
executable file
·57 lines (40 loc) · 1.47 KB
/
bootstrap.php
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
<?php
use Nette\Diagnostics\Debugger;
use Kdyby\Diagnostics\ConsoleDebugger;
// take care of autoloading
require_once __DIR__ . '/../autoload.php';
// additional php configurations
date_default_timezone_set("Europe/Prague");
// directories
$params = array(
'wwwDir' => __DIR__,
'appDir' => __DIR__,
'logDir' => __DIR__ . '/log',
'tempDir' => __DIR__ . '/temp',
);
// setup debugger
if (!is_writable($params['logDir'])) {
throw new Kdyby\DirectoryNotWritableException("Logging directory '" . $params['logDir'] . "' is not writable.");
}
Debugger::enable(Debugger::DEVELOPMENT);
Debugger::$logDirectory = $params['logDir'];
Debugger::$maxLen = 4096;
// ConsoleDebugger::enable('google-chrome %s');
// create configurator
if (!is_writable($params['tempDir'])) {
throw new Kdyby\DirectoryNotWritableException("Temp directory '" . $params['tempDir'] . "' is not writable.");
}
$configurator = new Kdyby\Tests\Configurator($params, new \Kdyby\Packages\DefaultPackages());
$configurator->setEnvironment('test');
$configurator->setProductionMode(TRUE);
// make container accessible globally
$container = $configurator->container;
Nette\Environment::setContext($container);
// start session on time
$container->session->start();
// delete exception reports from last run
foreach (Nette\Utils\Finder::findFiles('exception*.html', '*.log')->in($params['logDir']) as $file) {
@unlink($file->getRealpath());
}
// don't you dare to "backup globals"!
unset($params, $configurator, $container, $file);