I\'m new to Slim Framework. How to get the base URL like with the Codeigniter function base_url()?
Thanks
With Slim v3, as it implements PSR7, you can get a PSR7 Uri object and call the getBasePath() method that Slim3 adds on it. Simply write:
$basePath = $request->getUri()->getBasePath();
From Slim v3 documentation :
Base Path
If your Slim application's front-controller lives in a physical subdirectory beneath your document root directory, you can fetch the HTTP request's physical base path (relative to the document root) with the Uri object's getBasePath() method. This will be an empty string if the Slim application is installed in the document root's top-most directory.
Be aware that the getBasePath() method is added by the framework and is not part of PSR7 UriInterface.