This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
58 lines (46 loc) · 1.82 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
58
<?php
use Silex\Application;
use Silex\Provider\MonologServiceProvider;
use Silex\Provider\TwigServiceProvider;
use Silex\Provider\SymfonyBridgesServiceProvider;
//use Silex\Provider\SessionServiceProvider;
//use Silex\Provider\UrlGeneratorServiceProvider;
//use Silex\Provider\HttpCacheServiceProvider;
$app = new Application();
$app['debug'] = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'));
if ( $app['debug'] )
{
error_reporting(E_ALL);
@ini_set('display_errors', 1);
} else {
error_reporting(0);
@ini_set('display_errors', 0);
}
//$app->register(new SessionServiceProvider());
//$app->register(new UrlGeneratorServiceProvider());
$app->register(new SymfonyBridgesServiceProvider(), array(
'symfony_bridges.class_path' => __DIR__.'/vendor/symfony/src',
));
$app->register(new MonologServiceProvider(), array(
'monolog.logfile' => __DIR__.'/var/log/'.(($app['debug']) ? 'development' : 'production').'.'.date('Ymd').'.log',
'monolog.class_path' => __DIR__.'/vendor/monolog/src',
));
$app['monolog.level'] = ( $app['debug'] ) ? Monolog\Logger::DEBUG : Monolog\Logger::ERROR;
$app->register(new TwigServiceProvider(), array(
'twig.path' => __DIR__.'/tmp',
'twig.options' => array('debug' => $app['debug'], 'strict_variables' => $app['debug']),
'twig.class_path' => __DIR__.'/vendor/twig/lib'
));
$app['memcached.server'] = array('localhost', 11211);
$app['memcached'] = $app->share(function () use ($app) {
call_user_func_array(array($m = new Memcache, 'addServer'), $app['memcached.server']);
return $m;
});
$app['database.connection'] = $app->share(function() use($app) {
return new PDO('mysql:dbname=test', 'root');
});
$app['database'] = $app->share(function() use($app) {
require_once __DIR__.'/vendor/notorm/NotORM.php';
return new NotORM($app['database.connection']);
});
return $app;