-
Notifications
You must be signed in to change notification settings - Fork 11
/
app.php
60 lines (45 loc) · 1.56 KB
/
app.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
58
59
60
<?php
$loader = require __DIR__.'/vendor/autoload.php';
$mode = 'live';
if (array_key_exists('MODE', $_SERVER)) {
$mode = $_SERVER['MODE'];
} else {
if (file_exists(__DIR__.'/env.live')) {
$mode = 'live';
} elseif (file_exists(__DIR__.'/env.local')) {
$mode = 'local';
}
}
$logWriter = null;
$app = new \Slim\Slim(array('templates.path' => __DIR__.'/views/', 'mode' => $mode));
$env = $app->environment();
$app->configureMode('live', function () use ($app, $env) {
$env['URLBASE'] = 'http://nesbot.com';
$env['URLIMG'] = '/img/';
$env['URLFULLIMG'] = $env['URLBASE'] . $env['URLIMG'];
$env['URLCSS'] = '/css/';
$env['URLJS'] = '/js/';
$env['GATRACKER'] = 'UA-5684902-5';
$app->config('debug', false);
$logWriter = new \Slim\Extras\Log\DateTimeFileWriter(array('path' => __DIR__.'/../logs'));
});
$app->configureMode('local', function () use ($app, $env) {
$env['URLBASE'] = 'http://127.0.0.1';
$env['URLIMG'] = '/img/';
$env['URLFULLIMG'] = $env['URLBASE'] . $env['URLIMG'];
$env['URLCSS'] = '/css/';
$env['URLJS'] = '/js/';
//$env['GATRACKER'] = '';
$app->config('debug', true);
$out = array();
exec(sprintf("php %s/bundle.php", __DIR__), $out);
if (count($out) > 1) {
printf('<div><pre><code>%s</code></pre></div>', implode(PHP_EOL, $out));
}
$logWriter = new \Slim\Extras\Log\DateTimeFileWriter(array('path' => __DIR__.'/logs'));
});
$app->getLog()->setWriter($logWriter);
$posts = require 'posts.php';
$app->view(new BlogView($app, 'template.php', $posts));
require 'routes.php';
$app->run();