Added the hassankhan/config module
This commit is contained in:
23
src/app.php
23
src/app.php
@ -1,12 +1,25 @@
|
||||
<?php
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
use DI\Container;
|
||||
use Noodlehaus\Config;
|
||||
use Noodlehaus\Parser\Json;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Views\TwigMiddleware;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Load app configuration
|
||||
$config = Config::load(__DIR__ . '/../conf/defaults.json');
|
||||
|
||||
// Create new container object and add our config object to it
|
||||
$container = new Container();
|
||||
$container->set('config', function() use ($config) {
|
||||
return $config;
|
||||
});
|
||||
|
||||
// Set container to create App with on AppFactory
|
||||
AppFactory::setContainer($container);
|
||||
$app = AppFactory::create();
|
||||
|
||||
// Add Error Handling Middleware
|
||||
@ -18,7 +31,5 @@ $twig = Twig::create(__DIR__ . '/../views', ['cache' => false]);
|
||||
// Add Twig-View Middleware
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
|
||||
$app->get('/', function (Request $request, Response $response, $args) {
|
||||
$view = Twig::fromRequest($request);
|
||||
return $view->render($response, 'index.twig');
|
||||
});
|
||||
// load in route handlers
|
||||
require_once __DIR__ . '/routes.php';
|
||||
|
Reference in New Issue
Block a user