I\'m new to Slim Framework. How to get the base URL like with the Codeigniter function base_url()?
Thanks
In a recent app where we're using Twig, we assign the httpBasePath as follows:
$view = $app->view()->getEnvironment();
$view->addGlobal('httpBasePath', $app->request->getScriptName());
The addGlobal() method is probably equivalent to $app->view()->appendData(), I'm not sure.
The advantage of using $app->request->getScriptName() is that we don't have to manually set a folder name or care what it is – one developer can have the repo located at http://example.localhost and another can have it at http://localhost/projects/slim and no configuration is required.