Silex redirection in controller

50 Views Asked by At

I'm new in Silex and trying to figure out my way here.

I added a route in the controller but it seems to be not working.

The path of my pages is like this (same with laravel I create a layout which will yield the pages) So it goes like this

MyApp/templates/{List of all pages including the layout.html}

Now, in my MyApp/src/controllers.php

I placed a code (CODE 1.0)

$app->get('/a', function () use ($app) {
    return $app['twig']->render('login.html');
});

The login.html is location in MyApp/templates/.

The code above which is (CODE 1.1)

$app->get('/', function () use ($app) {
   $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]".dirname("$_SERVER[REQUEST_URI]") . "/YOURMD.md";

   return $app['twig']->render('index.html', [
    '   readme' => file_get_contents($actual_link),
   ]);
});

works. If I changed this part of the code above

return $app['twig']->render('index.html', [
    '   readme' => file_get_contents($actual_link),
   ]);

to

return $app['twig']->render('login.html');

it works.

Am I doing something wrong or do I missed something? Is there any other module I need to add or edit to achieve this?

Again, sorry for asking as I'm so new to Silex.

0

There are 0 best solutions below