4

I'm trying to do what I would think is the most basic thing and it is taking too much time. I simply want my index file to point to or forward to another file. I was originally doing this with a simple one liner.

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

Once I migrated to Silex I tried this:

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

but there was no go.

When I go to my site I get a very descriptive "Whoops Something went wrong". How can I troubleshoot this?

Here is the full code with all the boilerplate:

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 docs I'm using

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Well....you could turn debugging on for starters. – Andrei Jul 12 '15 at 23:48
  • `$app['debug'] = true;` - it's up –  Jul 12 '15 at 23:50
  • I assume you have a `.env` file in there somewhere, if you do, it may have another setting that overwrites the `$app['debug'] = true;` one. – Andrei Jul 12 '15 at 23:54
  • Debugging is on and working. I had to take out the $path variable, and now I got a new error - path not found. –  Jul 12 '15 at 23:56
  • `getcwd()` requires permission to actually work, hence, it's probably not giving you the full path. Although I fail to see it's necessity in the context you're using it. Some `$_SERVER` stuff should work fine too. – Andrei Jul 12 '15 at 23:59
  • It works fine, you got the answer if you want to mark it. `__DIR__` was needed, I don't know why. I've also used `getcwd()`, but were a bit off topic now. You answered the question in your first comment. Thanks. –  Jul 13 '15 at 00:02
  • Eh, I suppose I should Imaginary internet points are the best. – Andrei Jul 13 '15 at 00:04
  • That would be a great screen name - imaginary_internet_points –  Jul 13 '15 at 00:05

1 Answers1

0

Turn debugging on by doing $app['debug'] = true;.

If you have a .env file, also make sure it's not overwriting your default setting.

Andrei
  • 3,434
  • 5
  • 21
  • 44