I have a local file that I need included in a beginning Silex application. I just got started and I have all the boiler plate code setup - particularly here.
// I need to return test.php for this route
$app = new Silex\Application();
$app->get('/', function() use($app) {
return $string; // put the file in a string
});
$app->run();
After some googling I found these articles: SO, PHP.net
So it looks like I can use file_get_contents()
and if I need the code evaluated I could wrap it in eval()
. Or I could use the other method shown in the link.
I was hoping to just use something similar to require()
, but Silex needs a string returned. I imagine I could just write my own helper function parseFile()
but this has to be done somewhere else already?
Update
// this does not work, I'v verified the path is correct.
return file_get_contents($path, TRUE);