- 29 Mar, 2011 1 commit
-
-
Igor Wiedler authored
-
- 28 Mar, 2011 4 commits
-
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
Usage: $app = new Application(); $app->register(new TranslationExtension(), array( 'translation.class_path' => '...', )); $app['translator.messages'] = array( 'en' => array( 'apple' => 'apple', ), 'fr' => array( 'apple' => 'pomme', ), ); $app['locale'] = 'fr'; echo $app['translator']->trans('apple'); If you use the Symfony Bridge extension, some tags and filters are also automatically available in templates: $templates = array( 'index' => '{% trans %}apple{% endtrans %}' );
-
Fabien Potencier authored
For now, it allows the Twig extension to register the Routing Twig extension: $app = new Application(); $app->register(new SymfonyBridgesExtension(), array( 'symfony_bridges.class_path' => '...', )); $app->register(new UrlGeneratorExtension()); $app->register(new SessionExtension()); $app->register(new TwigExtension(), array(...)); You can now use {{ path() }} in templates to generate URLs. The order of registration of the extensions is significant.
-
- 27 Mar, 2011 20 commits
-
-
Fabien Potencier authored
-
Fabien Potencier authored
* igorw/urlgenerator: [UrlGeneratorExtension] service for generating URLs for routes
-
Fabien Potencier authored
* igorw/beforefilter-httpexception: [Application] onSilexBefore should fire on BaseHttpException
-
Igor Wiedler authored
Usage example: $app->register(new UrlGeneratorExtension()); $app->get('/hello/:name', function($name) { return "Hello $name!"; }) ->bind('hello'); $app->get('/go', function() use ($app) { $url = $app['url_generator']->generate('hello', array('name' => 'Fabien')); return $app->redirect($url); }); Thanks to @choffmeister.
-
Igor Wiedler authored
-
Igor Wiedler authored
-
Igor Wiedler authored
Sample usage: $app = new Application(); $app->register(new MonologExtension(), array( 'monolog.class_path' => __DIR__.'/vendor/monolog/src', 'monolog.logfile' => __DIR__.'/application.log', )); $app->get('/hello', function() use ($app) { $app['monolog']->addDebug('currently at hello'); return 'Hello World!'; }); $app->get('/error', function() { throw new RuntimeException('Some error'); }); $app->run();
-
Fabien Potencier authored
This is also to avoid confusion with the fluid interface we now have for controllers.
-
Fabien Potencier authored
$app->get('/{id}', function($id) { // ... })->assert('id', '\d+');
-
Fabien Potencier authored
Usage: use Silex\Application; use Silex\Extension\TwigExtension; require_once __DIR__.'/silex.phar'; $app = new Application(); $templates = array( 'hello' => 'Hello {{ name }}', ); $app->register(new TwigExtension(), array( 'twig.templates' => $templates, 'twig.class_path' => '/path/to//Twig/lib', )); $app->get('/{name}', function($name) use ($app) { return $app['twig']->render('hello', array('name' => $name)); }); $app->run();
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
Usage example: $app->register(new TwigExtension(), array( 'twig.path' => __DIR__.'/templates', 'twig.options' => array('cache' => __DIR__.'/../cache', 'debug' => true, 'strict_variables' => true), 'twig.configure' => $app->protect(function ($twig) use ($app) { $twig->addExtension(...); }) ));
-
Fabien Potencier authored
-
Fabien Potencier authored
-
- 26 Mar, 2011 9 commits
-
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
-
Fabien Potencier authored
Usage: $app = new Application(); $app->register(new TwigExtension(), array( 'twig.path' => __DIR__.'/../templates', 'twig.options' => array('cache' => __DIR__.'/../cache', 'debug' => true), )); The "app" variable is registered as a global variable, so it is accessible in all templates: $app['routing'] = new UrlGenerator(...); {{ app.routing.generate('homepage') }}
-
Fabien Potencier authored
-
Fabien Potencier authored
You can now use the app instance to store objects or parameters: $app = new Application(); $app['twig'] = new \Twig_Environment(...); $app['debug'] = true; $app->get('/', function() use ($app) { return $app['twig']->load('index.html')->render(array()); }); For sercices, you can even make them lazy loaded and/or shared: $app['twig'] = $app->asShared(function () { return \Twig_Environment(...); });
-
Fabien Potencier authored
-
Fabien Potencier authored
-
- 25 Mar, 2011 6 commits
-
-
Fabien Potencier authored
-
Igor Wiedler authored
-
Igor Wiedler authored
-
Igor Wiedler authored
-
Igor Wiedler authored
-
Igor Wiedler authored
-