-
-
Save mekanics/1584765 to your computer and use it in GitHub Desktop.
Revisions
-
docteurklein created this gist
Apr 8, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ <?php require_once __DIR__.'/../Silex/silex.phar'; use Silex\Extension\DoctrineExtension; $app = new Silex\Application; $app->register(new DoctrineExtension, array( 'doctrine.dbal.connection_options' => array( 'driver' => 'pdo_mysql', 'dbname' => 'test', 'host' => 'localhost', 'user' => 'root', 'password' => null ), 'doctrine.orm' => true, 'doctrine.orm.entities' => array( array('type' => 'annotation', 'path' => __DIR__.'/Entity', 'namespace' => 'Entity'), ), 'doctrine.common.class_path' => __DIR__.'/vendor/doctrine_common/lib', 'doctrine.dbal.class_path' => __DIR__.'/vendor/doctrine_dbal/lib', 'doctrine.orm.class_path' => __DIR__.'/vendor/doctrine_orm/lib', )); $app['autoloader']->registerNamespace('Entity', __DIR__); $app->get('/', function() use($app) { $conn = $app['doctrine.dbal.connection']; $categories = print_r($conn->query('SELECT * FROM category')->fetchAll(), true); return 'Hello <pre>'.$categories.'</pre>'; }); $app->get('/category/{slug}', function($slug) use($app) { $em = $app['doctrine.orm.em']; $entity = $em->getRepository('Entity\Category')->findOneBy(array('slug' => $slug)); return 'Hello '.$entity; }); $app->run();