Skip to content

Instantly share code, notes, and snippets.

@umpirsky
Created February 13, 2012 13:56
Show Gist options
  • Save umpirsky/1817117 to your computer and use it in GitHub Desktop.
Save umpirsky/1817117 to your computer and use it in GitHub Desktop.
app.php
<?php
include __DIR__ . '/../vendor/silex/autoload.php';
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
$app = new Silex\Application();
// Register extensions
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__ . '/../views',
'twig.class_path' => __DIR__ . '/../vendor/twig/lib',
));
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$app->register(new Silex\Provider\FormServiceProvider(), array(
'form.class_path' => __DIR__ . '/../vendor/symfony/src'
));
$app->register(new Silex\Provider\SymfonyBridgesServiceProvider(), array(
'symfony_bridges.class_path' => __DIR__ . '/../vendor/symfony/src'
));
// Add layout
$app->before(function () use ($app) {
$app['twig']->addGlobal('layout', $app['twig']->loadTemplate('layout.twig'));
});
$app->get('/', function () use ($app) {
return $app['twig']->render('about.twig');
})->bind('about');
// Run
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment