File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 24
24
use Slim \Views \Twig ;
25
25
use Slim \Views \TwigMiddleware ;
26
26
27
+ // Create and set the dependency injection container.
27
28
$ container = new Container ;
28
29
AppFactory::setContainer (new Psr11Container ($ container ));
29
- $ app = AppFactory::create ();
30
30
31
+ // add the votes manager to the container.
31
32
$ container ['votes ' ] = function (Container $ container ) {
32
33
return new Votes ($ container ['db ' ]);
33
34
};
34
35
36
+ // Setup the database connection in the container.
35
37
$ container ['db ' ] = function () {
36
38
$ username = getenv ("DB_USER " );
37
39
$ password = getenv ("DB_PASS " );
75
77
return $ conn ;
76
78
};
77
79
80
+ // Configure the templating engine.
78
81
$ container ['view ' ] = function () {
79
82
return Twig::create (__DIR__ . '/../views ' );
80
83
};
81
84
85
+ // Create the application.
86
+ $ app = AppFactory::create ();
87
+
88
+ // Add the twig middleware
82
89
$ app ->add (TwigMiddleware::createFromContainer ($ app ));
83
90
91
+ // Setup error handlinmg
84
92
$ app ->addErrorMiddleware (true , false , false );
85
93
86
94
return $ app ;
You can’t perform that action at this time.
0 commit comments