DIR is a magic constant as stated in the PHP docs. getcwd() is just the current working directory according to the PHP docs.
My use case is:
// this is my index.php file
require_once __DIR__ . '/vendor/autoload.php';
$app = new Silex\Application();
$app['debug'] = true;
$app->get('/{name}', function($name) use($app) {
return $app->sendFile(__DIR__ . '/web/source/index.php');
});
I don't fully understand why I need either of these mechanisms as I should just be able to use relative paths.
However the code fails with out it.