Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require __DIR__ . '/vendor/autoload.php';
- use Symfony\Component\HttpFoundation\Response;
- use DUT\Services\SessionStorage;
- use Doctrine\ORM\Tools\Setup;
- use Doctrine\ORM\EntityManager;
- $storage = new SessionStorage();
- $app['em'] = function ($app) {
- return EntityManager::create($app['connection'], $app['doctrine_config']);
- };
- //Config
- $app = new Silex\Application();
- $app->register(new Silex\Provider\UrlGeneratorServiceProvider());
- $app->register(new Silex\Provider\TwigServiceProvider(), ['twig.path' => __DIR__.'/views',]);
- $app['connection'] = [ 'driver' => 'pdo_mysql', 'host' => 'localhost', 'user' => 'p1506012', 'password' => '11506012', 'dbname' => 'p1506012'];
- $app['doctrine_config'] = Setup::createYAMLMetadataConfiguration([__DIR__ . '/yaml'], true);
- $app['em'] = function ($app) {
- return EntityManager::create($app['connection'], $app['doctrine_config']);
- };
- /**
- * ROUTES
- */
- $app->get('/creerCpt', function() use ($app)
- {
- $entityManager=$app['em'];
- return $app['twig']->render('AccountCreationPage.twig');
- }
- );
- $app->get('/connexion', function() use ($app)
- {
- $entityManager=$app['em'];
- return $app['twig']->render('ConnexionPage.twig');
- }
- );
- $app->post('/connexion', 'DUT\\Controllers\\UserController::connect')
- ->bind('connexion');
- $app->post('/creerCpt', 'DUT\\Controllers\\UserController::create')
- ->bind('createAcc');
- //Afficher toutes la base:
- $app->get('/', function() use($app){
- $entityManager=$app['em'];
- return $app['twig']->render('Home.twig');
- })
- ->bind('home');
- $app['debug'] = true;
- $app->run();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement