src/Path.php
public static function makeAbsolute($path, $basePath)
    {
        Assert::stringNotEmpty($basePath, 'The base path must be a non-empty string. Got: %s');

        if (!static::isAbsolute($basePath)) {
            throw new InvalidArgumentException(sprintf(
                'The base path "%s" is not an absolute path.',
                $basePath
            ));
        }

        if (static::isAbsolute($path)) {
            return static::canonicalize($path);
        }

        if (false !== ($pos = strpos($basePath, '://'))) {
            $scheme = substr($basePath, 0, $pos + 3);
            $basePath = substr($basePath, $pos + 3);
        } else {
            $scheme = '';
        }

        return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
    }
public static function makeAbsolute($path, $basePath)
    {
        Assert::stringNotEmpty($basePath, 'The base path must be a non-empty string. Got: %s');

        if (!static::isAbsolute($basePath)) {
            throw new InvalidArgumentException(sprintf(
                'The base path "%s" is not an absolute path.',
                $basePath
            ));
        }

        if (static::isAbsolute($path)) {
            return static::canonicalize($path);
        }

        if (false !== ($pos = strpos($basePath, '://'))) {
            $scheme = substr($basePath, 0, $pos + 3);
            $basePath = substr($basePath, $pos + 3);
        } else {
            $scheme = '';
        }

        return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
    }
public static function makeAbsolute ( $ path , $ basePath ) { Assert :: stringNotEmpty ( $ basePath , 'The base path must be a non-empty string. Got: %s' ) ; if ( ! static :: isAbsolute ( $ basePath ) ) { throw new InvalidArgumentException ( sprintf ( 'The base path "%s" is not an absolute path.' , $ basePath ) ) ; } if ( static :: isAbsolute ( $ path ) ) { return static :: canonicalize ( $ path ) ; } if ( false !== ( $ pos = strpos ( $ basePath , '://' ) ) ) { $ scheme = substr ( $ basePath , 0 , $ pos + 3 ) ; $ basePath = substr ( $ basePath , $ pos + 3 ) ; } else { $ scheme = '' ; } return $ scheme . self :: canonicalize ( rtrim ( $ basePath , '/\\' ) . '/' . $ path ) ; }
Turns a relative path into an absolute path.

Usually, the relative path is appended to the given base path. Dot
segments ("." and "..") are removed/collapsed and all slashes turned
into forward slashes.

```php
echo Path::makeAbsolute("../style.css", "/webmozart/puli/css");
// => /webmozart/puli/style.css
```

If an absolute path is passed, that path is returned unless its root
directory is different than the one of the base path. In that case, an
exception is thrown.

```php
Path::makeAbsolute("/style.css", "/webmozart/puli/css");
// => /style.css

Path::makeAbsolute("C:/style.css", "C:/webmozart/puli/css");
// => C:/style.css

Path::makeAbsolute("C:/style.css", "/webmozart/puli/css");
// InvalidArgumentException
```

If the base path is not an absolute path, an exception is thrown.

The result is a canonical path.

@param string $path     A path to make absolute.
@param string $basePath An absolute base path.

@return string An absolute path in canonical form.

@throws InvalidArgumentException If the base path is not absolute or if
the given path is an absolute path with
a different root than the base path.

@since 1.0   Added method.
@since 2.0   Method now fails if $path or $basePath is not a string.
@since 2.2.2 Method does not fail anymore of $path and $basePath are
absolute, but on different partitions.
Turns a relative path into an absolute path .