|
13 | 13 | // Register an autoloader |
14 | 14 | $loader = new Loader(); |
15 | 15 | $loader->registerDirs( |
16 | | - array( |
| 16 | + [ |
17 | 17 | APP_PATH . '/controllers/', |
18 | | - APP_PATH . '/models/' |
19 | | - ) |
20 | | -)->register(); |
| 18 | + APP_PATH . '/models/', |
| 19 | + ] |
| 20 | +)->register() |
| 21 | +; |
21 | 22 |
|
22 | 23 | // Create a DI |
23 | 24 | $di = new FactoryDefault(); |
24 | 25 |
|
25 | 26 | // Setting up the view component |
26 | | -$di['view'] = function() { |
| 27 | +$di['view'] = function () { |
27 | 28 | $view = new View(); |
28 | 29 | $view->setViewsDir(APP_PATH . '/views/'); |
29 | 30 | return $view; |
30 | 31 | }; |
31 | 32 |
|
32 | 33 | // Setup a base URI so that all generated URIs include the "tutorial" folder |
33 | | -$di['url'] = function() { |
| 34 | +$di['url'] = function () { |
34 | 35 | $url = new UrlProvider(); |
35 | 36 | $url->setBaseUri('/'); |
36 | 37 | return $url; |
37 | 38 | }; |
38 | 39 |
|
39 | 40 | // Set the database service |
40 | | -$di['db'] = function() { |
41 | | - return new DbAdapter(array( |
42 | | - "host" => "127.0.0.1", |
43 | | - "username" => "root", |
44 | | - "password" => "secret", |
45 | | - "dbname" => "tutorial1" |
46 | | - )); |
| 41 | +$di['db'] = function () { |
| 42 | + return new DbAdapter([ |
| 43 | + "host" => getenv('DATA_MYSQL_HOST'), |
| 44 | + "username" => getenv('DATA_MYSQL_USER'), |
| 45 | + "password" => getenv('DATA_MYSQL_PASS'), |
| 46 | + "dbname" => "gonano", |
| 47 | + ]); |
47 | 48 | }; |
48 | 49 |
|
49 | 50 | // Handle the request |
50 | 51 | try { |
51 | 52 | $application = new Application($di); |
52 | 53 | echo $application->handle()->getContent(); |
53 | 54 | } catch (Exception $e) { |
54 | | - echo "Exception: ", $e->getMessage(); |
| 55 | + echo "Exception: ", $e->getMessage(); |
55 | 56 | } |
0 commit comments