Created
April 5, 2012 07:41
-
-
Save pascalopitz/2308810 to your computer and use it in GitHub Desktop.
This file contains 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 __DIR__.'/bootstrap.php'; | |
$app->get('/', function() use($app) { | |
return $app['twig']->render('index.html.twig'); | |
}); | |
$app->mount('/test', new \Testapp\Controller\Test()); |
This file contains 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 | |
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