KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to render a Symfony form using twig in a Silex application. I'm using Symfony 2 Form library, Symfony Bridge Twig Forms Extension and Twig. Here is my bootsrap file: require_once __DIR__ . '/../app/silex.phar'; $app = new Silex\Application(); $app['debug'] = true; // Set up the autoloader require_once __DIR__ . '/../app/vendor/.composer/autoload.php'; // Load Configuration into container $parser = new Symfony\Component\Yaml\Parser(); $config = $parser->parse(file_get_contents(__DIR__ . '/../app/config/config.yml')); $app['config'] = $config; // Set up Symfony bridge (nice twig functions) $app->register(new Silex\Provider\SymfonyBridgesServiceProvider(), array( 'symfony_bridges.class_path' => __DIR__ . '/vendor/symfony/twig-bridge', )); // Set Up Templating $app->register(new Silex\Provider\TwigServiceProvider(), array( 'twig.path' => __DIR__ . '/../app/views', 'twig.class_path' => __DIR__ . '/../app/vendor/twig/twig/lib', )); // Set Up Database $app->register(new Silex\Provider\DoctrineServiceProvider(), array( 'db.options' => array( 'driver' => $app['config']['db']['driver'], 'host' => $app['config']['db']['host'], 'user' => $app['config']['db']['user'], 'password' => $app['config']['db']['password'], 'dbname' => $app['config']['db']['dbname'] ), 'db.dbal.class_path' => __DIR__ . '/vendor/doctrine/doctrine-dbal/lib', 'db.common.class_path' => __DIR__ . '/vendor/doctrine/doctrine-common/lib', )); // Set up the Symfony forms component $app->register(new Silex\Provider\FormServiceProvider()); // Routes $app->get('/', function() use($app) { return $app['twig']->render('index.twig', array()); }); $app->get('/info', function() use($app) { return $app['twig']->render('info.twig', array()); }); $app->get('/register', function() use($app) { $builder = $app['form.factory']->createBuilder(new MppInt\Form\Type\RegisterType() )
Tags (comma-separated)
Save Edits
Cancel