Returns the base path of the request.

@param   boolean $fqp If TRUE create a fully qualified path. Default FALSE.
@return  string
972486
public function getBasePath($fqp = false)
    {
        if(!isset($this->_base_path))
        {
            // PHP-CGI on Apache with "cgi.fix_pathinfo = 0". We don't have user-supplied PATH_INFO in PHP_SELF
            if (strpos(PHP_SAPI, 'cgi') !== false && !ini_get('cgi.fix_pathinfo')  && !empty($_SERVER['REQUEST_URI'])) {
                $path = $_SERVER['PHP_SELF'];
            } else {
                $path = $_SERVER['SCRIPT_NAME'];
            }

            $this->_base_path = rtrim(dirname($path), '/\\');
        }

        return $fqp ? $_SERVER['DOCUMENT_ROOT'].$this->_base_path : $this->_base_path;
    }
654507
public static function getRelativePath($path, $base = GRAV_ROOT)
    {
        if ($base) {
            $base = preg_replace('![\\\/]+!', '/', $base);
            $path = preg_replace('![\\\/]+!', '/', $path);
            if (strpos($path, $base) === 0) {
                $path = ltrim(substr($path, strlen($base)), '/');
            }
        }

        return $path;
    }
135290
public static function path(&$path, bool $validate=true) {
		if (\is_array($path)) {
			foreach ($path as $k=>$v) {
				static::path($path[$k], $validate);
			}
		}
		else {
			cast::string($path, true);

			// This might be a URL rather than something local.
			// Only focus on the main ones.
			if (\preg_match('/^(https?|ftps?|sftp)/iu', $path)) {
				sanitize::url($path);
				return true;
			}

			// Strip leading file:// scheme.
			if (0 === \strpos($path, 'file://')) {
				$path = \substr($path, 7);
			}

			static::unixslash($path);

			$original = $path;
			try {
				$path = @\realpath($path);
			} catch (\Throwable $e) {
				$path = false;
			}

			if ($validate && (false === $path)) {
				$path = false;
				return false;
			}
			elseif (false === $path) {
				// Try just the directory.
				try {
					$path = $original;
					if (false !== $dir = @\realpath(\dirname($path))) {
						static::trailingslash($dir);
						$path = $dir . \basename($path);
					}
					else {
						$path = $original;
					}
				} catch (\Throwable $e) {
					$path = $original;
				}
			}

			$original = $path;
			try {
				if (@\is_dir($path)) {
					static::trailingslash($path);
				}
			} catch (\Throwable $e) {
				$path = $original;
			}
		}

		return true;
	}
1051421
public function base($path = null)
    {
        return ($this->baseUrl ? rtrim($this->baseUrl, '/' ).'/' : '/').($path ? trim($path, '/') : '');
    }
533218
public function getBasePath()
    {
        if (isset($this->raw->{'base-path'})) {
            if (false === is_dir($this->raw->{'base-path'})) {
                throw new InvalidArgumentException(
                    sprintf(
                        'The base path "%s" is not a directory or does not exist.',
                        $this->raw->{'base-path'}
                    )
                );
            }

            return realpath($this->raw->{'base-path'});
        }

        return realpath(dirname($this->file));
    }
444718
public function getRequestedRoute($basepath)
    {
        if ($basepath == '/') {
            $url = strtolower($_SERVER['REQUEST_URI']);
        } else {
            $url = explode($basepath, strtolower($_SERVER['REQUEST_URI']))[1];
        }

        return $this->_router->getRoute($url);
    }
1305109
public static function base($path = '')
    {
        // Check for cached version of base path
        if (null !== self::$base) {
            return self::$base . $path;
        }

        if (isset($_SERVER['HTTP_HOST'])) {
            $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
            $base_url .= '://' . $_SERVER['HTTP_HOST'];
            $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
            self::$base = $base_url;

            return $base_url . $path;
        }
        return '';
    }
551845
private static function getBasePath()
    {
        if (empty(self::$basePath)) {
            self::$basePath = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, self::BASE_PATH_NAME);
        }
        return self::$basePath;
    }
1242763
protected function _getBasePath($plugin = false)
    {
        if ($plugin !== false) {
            return $this->_getPluginPath($plugin) . 'webroot' . DS;
        }

        return WWW_ROOT;
    }
161559
protected function _getBaseAssetPath($plugin = false)
    {
        if ($plugin !== false) {
            return $this->_getPluginPath($plugin) . 'src' . DS . 'Assets' . DS;
        }

        return ROOT . DS . 'src' . DS . 'Assets' . DS;
    }
298993
public function compilePath($path = false)
    {
        $currentBasePath = $this->getManager()->getCurrent()->getPath();
        $path = str_replace($currentBasePath, $this->getPath(), $path);
        return $path;
    }
1117525
private function getPath($path)
    {
        if ($this->basePath === '' || strpos($path, $this->basePath) === 0) {
            $path = substr($path, strlen($this->basePath)) ?: '';
        }

        return $path === '' ? '/' : $path;
    }
550675
public function getBasePath()
    {
        if (null == $this->basePath) {
            $this->basePath = strtolower($this->controllerName);
        }
        return $this->basePath;
    }
669065
public function getUrl($path)
    {
        $regExp = '/\/\/|https?:/i';
        if (preg_match($regExp, $path)) {
            return $path;
        }
        try {
            $generated = call_user_func_array(
                [$this->getRouterGenerator(), 'generate'],
                func_get_args()
            );
        } catch (AuraException $caught) {
            $generated = false;
        }

        $basePath = rtrim($this->getRequest()->getBasePath(), '/');
        $path = $generated
            ? $generated
            : "{$basePath}/{$path}";

        return $path;
    }
1338774
public function getAssetPath(string $path)
    {
        if (!$this->urlHelper->isFullUrl($path)) {
            $path = $this->pathHelper->prefix($path);
        }

        return $this->urlHelper->getUrl(self::BASE_URL.$path);
    }
909093
public function getBasePath($offset = 0, $format = self::FORMAT_NO_DELIMITERS)
	{
		$basePathList = $this->basePathParts;
		
		if ($offset > 0) {
			$basePathList = array_slice($basePathList, 0, -$offset);
		}
		
		$parts = new Path('', $this->separator);
		
		foreach ($basePathList as $path) {
			$parts->append($path);
		}
		
		$basePathString = $parts->getFullPath($format);
		
		return $basePathString;
	}
540133
public function getBasePath() 
    {
        $basePath = str_replace($this->getScript(), '', $this->getScriptUrl());
        $basePath = '/' . ltrim($basePath, '/');
        return $basePath;
    }