-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
48 lines (33 loc) · 1.01 KB
/
index.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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
include 'vendor/autoload.php';
use Phlyty\App;
use Snailfinder\ErrorHandler;
use Snailfinder\LogProcessor;
use Snailfinder\ReportBuilder;
use Snailfinder\PhpView;
$app = new App();
$errorHandler = new ErrorHandler();
$app->events()->attach('500', $errorHandler);
$app->events()->attach('501', $errorHandler);
$app->setView(new PhpView());
$app->get('/', function(App $app){
$viewModel = array(
'path' => '/var/log/php5-fpm.slow.log',
);
$app->render('index', $viewModel);
});
$app->get('/generate', function(App $app){
$processor = new LogProcessor();
$entries = $processor->parse($app->request()->getQuery('path'));
$reportBuilder = new ReportBuilder();
$reportBuilder->build($entries);
$viewModel = array(
'path' => $app->request()->getQuery('path', ''),
'error' => $processor->getError()
);
$app->render('index', $viewModel);
});
$app->run();