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 2424use Slim \Views \Twig ;
2525use Slim \Views \TwigMiddleware ;
2626
27+ // Create and set the dependency injection container.
2728$ container = new Container ;
2829AppFactory::setContainer (new Psr11Container ($ container ));
29- $ app = AppFactory::create ();
3030
31+ // add the votes manager to the container.
3132$ container ['votes ' ] = function (Container $ container ) {
3233 return new Votes ($ container ['db ' ]);
3334};
3435
36+ // Setup the database connection in the container.
3537$ container ['db ' ] = function () {
3638 $ username = getenv ("DB_USER " );
3739 $ password = getenv ("DB_PASS " );
7577 return $ conn ;
7678};
7779
80+ // Configure the templating engine.
7881$ container ['view ' ] = function () {
7982 return Twig::create (__DIR__ . '/../views ' );
8083};
8184
85+ // Create the application.
86+ $ app = AppFactory::create ();
87+
88+ // Add the twig middleware
8289$ app ->add (TwigMiddleware::createFromContainer ($ app ));
8390
91+ // Setup error handlinmg
8492$ app ->addErrorMiddleware (true , false , false );
8593
8694return $ app ;
You can’t perform that action at this time.
0 commit comments