Ejemplo n.º 1
0
 protected function createApplication(LoggerInterface $logger, $debug = true)
 {
     $configuration = array('root' => __DIR__, 'debug' => $debug, 'security.firewalls' => array('secured' => array('pattern' => '^/account$', '_controller' => function (Request $request, Response $response, Authentication $auth) {
         if (!$auth->check($request)) {
             return $response->redirect('/login');
         }
     }, 'response' => new Response(), 'auth' => new Authentication())));
     $dispatcher = new EventDispatcher();
     $frontendController = $this->createFrontendController($configuration, $this->logger);
     return ApplicationFactory::build($configuration, $dispatcher, $frontendController);
 }
Ejemplo n.º 2
0
<?php

require_once __DIR__ . '/bootstrap.php';
use Minima\Provider\DatabaseProvider;
use Minima\Provider\LoggerProvider;
use Minima\Http\Request;
use Minima\FrontendController\FrontendController;
use Symfony\Component\EventDispatcher\EventDispatcher;
// Configuration
$configuration = array('root' => __DIR__);
// Stateful Components
$dispatcher = new EventDispatcher();
$database = DatabaseProvider::getConnection();
$frontendController = FrontendController::build($configuration);
// Add your routes here
// Build Application
$application = ApplicationFactory::build($configuration, $dispatcher, $frontendController);
// Handle the request
$request = Request::createFromGlobals();
$response = $application->handle($request);
$response->send();