Skip to content

Instantly share code, notes, and snippets.

@pascalopitz
Created April 5, 2012 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pascalopitz/2308810 to your computer and use it in GitHub Desktop.
Save pascalopitz/2308810 to your computer and use it in GitHub Desktop.
<?php
require_once __DIR__.'/bootstrap.php';
$app->get('/', function() use($app) {
return $app['twig']->render('index.html.twig');
});
$app->mount('/test', new \Testapp\Controller\Test());
<?php
namespace Testapp\Controller;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Testapp\Form;
class Test implements ControllerProviderInterface
{
public function connect(Application $app) {
$db = $app['db'];
$controllers = new ControllerCollection();
$controllers->get('/', function() use($db) {
$collection = $db->local;
var_dump($collection);
$c = $collection->find();
while($c->hasNext()) {
var_dump($c->getNext());
}
});
$controllers->get('/create', function() use($app, $db) {
$form = $app['form.factory']->create(new Form\Test());
return $app['twig']->render('test/create.html.twig', array(
'form' => $form->createView(),
));
});
return $controllers;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment