-
-
Save jamiehollern/6cdc6aba4ce20e04ecf93183c85f8a9f to your computer and use it in GitHub Desktop.
This is the simple silex app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname(__DIR__) . '/vendor/autoload.php'; | |
use Silex\Application; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
$app = new Silex\Application(); | |
$app['debug'] = true; | |
$app->register(new Silex\Provider\SecurityServiceProvider()); | |
$app->register(new Silex\Provider\SessionServiceProvider()); | |
$app->register(new Silex\Provider\TwigServiceProvider(), array( | |
'twig.path' => dirname(__DIR__) . '/src/views' | |
)); | |
$app->register(new Silex\Provider\UrlGeneratorServiceProvider()); | |
$app['security.firewalls'] = array( | |
'admin' => array( | |
'pattern' => '^/admin/?', | |
'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), | |
'logout' => array('logout_path' => '/logout'), | |
'users' => array( | |
'admin' => array('ROLE_ADMIN', '5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg=='), | |
), | |
), | |
); | |
$app->get('/', function(Request $request) use ($app) { | |
return new Response('index', 200); | |
}); | |
$app->get('/admin', function(Request $request) use ($app) { | |
return new Response('admin', 200); | |
}); | |
$app->get('/logout', function() use ($app) { | |
return new Response('logout', 200); | |
}); | |
$app->get('/login', function(Request $request) use ($app) { | |
return $app['twig']->render('login.twig', array( | |
'error' => $app['security.last_error']($request), | |
'last_username' => $app['session']->get('_security.last_username'), | |
)); | |
}); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment