3 namespace Friendica\Util;
8 * @brief Returns the base filesystem path of the App
10 * It first checks for the internal variable, then for DOCUMENT_ROOT and
13 * @param string|null $basePath The default base path
14 * @param array $server server arguments
18 * @throws \Exception if directory isn't usable
20 public static function create($basePath, $server = [])
22 if (!$basePath && !empty($server['DOCUMENT_ROOT'])) {
23 $basePath = $server['DOCUMENT_ROOT'];
26 if (!$basePath && !empty($server['PWD'])) {
27 $basePath = $server['PWD'];
30 return self::getRealPath($basePath);
34 * @brief Returns a normalized file path
36 * This is a wrapper for the "realpath" function.
37 * That function cannot detect the real path when some folders aren't readable.
38 * Since this could happen with some hosters we need to handle this.
40 * @param string $path The path that is about to be normalized
41 * @return string normalized path - when possible
43 public static function getRealPath($path)
45 $normalized = realpath($path);
47 if (!is_bool($normalized)) {