Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <?php
  2. require __DIR__ . '/vendor/autoload.php';
  3.  
  4. use Symfony\Component\HttpFoundation\Response;
  5. use DUT\Services\SessionStorage;
  6. use Doctrine\ORM\Tools\Setup;
  7. use Doctrine\ORM\EntityManager;
  8.  
  9. $storage = new SessionStorage();
  10.  
  11. $app['em'] = function ($app) {
  12. return EntityManager::create($app['connection'], $app['doctrine_config']);
  13. };
  14.  
  15. //Config
  16. $app = new Silex\Application();
  17. $app->register(new Silex\Provider\UrlGeneratorServiceProvider());
  18. $app->register(new Silex\Provider\TwigServiceProvider(), ['twig.path' => __DIR__.'/views',]);
  19.  
  20. $app['connection'] = [ 'driver' => 'pdo_mysql', 'host' => 'localhost', 'user' => 'p1506012', 'password' => '11506012', 'dbname' => 'p1506012'];
  21.  
  22. $app['doctrine_config'] = Setup::createYAMLMetadataConfiguration([__DIR__ . '/yaml'], true);
  23.  
  24. $app['em'] = function ($app) {
  25. return EntityManager::create($app['connection'], $app['doctrine_config']);
  26. };
  27.  
  28.  
  29. /**
  30. * ROUTES
  31.  
  32. */
  33.  
  34. $app->get('/creerCpt', function() use ($app)
  35. {
  36. $entityManager=$app['em'];
  37. return $app['twig']->render('AccountCreationPage.twig');
  38. }
  39. );
  40.  
  41. $app->get('/connexion', function() use ($app)
  42. {
  43. $entityManager=$app['em'];
  44. return $app['twig']->render('ConnexionPage.twig');
  45. }
  46. );
  47.  
  48. $app->post('/connexion', 'DUT\\Controllers\\UserController::connect')
  49. ->bind('connexion');
  50.  
  51. $app->post('/creerCpt', 'DUT\\Controllers\\UserController::create')
  52. ->bind('createAcc');
  53.  
  54. //Afficher toutes la base:
  55. $app->get('/', function() use($app){
  56. $entityManager=$app['em'];
  57. return $app['twig']->render('Home.twig');
  58. })
  59. ->bind('home');
  60.  
  61. $app['debug'] = true;
  62. $app->run();
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement