How to fix the problem using the Silex application?

I am trying to do what, in my opinion, is the most basic, and it takes too much time. I just want my index file to point or forward another file. I initially did this with a simple one liner.

require_once getcwd() . "/web/source/index.php";

As soon as I switched to Silex, I tried this:

$app->get('/', function($path) use($app) {
    return $app->sendFile('/web/source/index.php');
});

but there was no way out.

When I go to my site, I get a very descriptive message "Whoops Something went wrong." How to fix this problem?

Here is the complete code with the whole template:

require_once __DIR__ . '/vendor/autoload.php';
$app = new Silex\Application();
$app->get('/{name}', function($name) use($app) { 
    // this works fine
    return ' test: '. $app->escape($name);
});

$app->get('/', function($path) use($app) {
    // this does not
    return $app->sendFile('/web/source/index.php');
});

$app->run();

Here are the documents I use

+4
source share
1 answer

Enable debugging by completing $app['debug'] = true;.

.env, , .

0

All Articles