PathResolver
A utility to resolve paths to their canonical location and handle path queries.
class Winter\Storm\Filesystem\PathResolver
Methods
public
static
join (string $prefix, string $path = ""
)
: string
Join two paths, making sure they use the correct directory separators.
Property | Type | Description |
---|---|---|
$prefix | string |
string
|
$path | string |
string
|
public static resolve (string $path) : string | bool
Resolves a path to its canonical location.
This expands all symbolic links and resolves references to /./, /../ and extra / characters in the input path and returns the canonicalized absolute pathname.
This function operates very similar to the PHP realpath
function, except it will also work for missing files
and directories.
Returns canonical path if it can be resolved, otherwise false
.
Property | Type | Description |
---|---|---|
$path | string |
string
|
public static standardize (string $path) : string
Standardizes the path separators of a path back to the expected separator for the operating system.
Property | Type | Description |
---|---|---|
$path | string |
string
|
public static within (string $path, string $directory) : bool
Determines if the path is within the given directory.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$directory | string |
string
|
protected
static
normalize (string $path, boolean $applyCwd = true
)
: string
Normalizes a given path.
Converts any type of path (Unix or Windows) into a Unix-style path, so that we have a consistent format to work with internally. All paths will be returned with no trailing path separator.
If $applyCwd
is true, the current working directory will be prepended if the path is relative.
Property | Type | Description |
---|---|---|
$path | string |
string
|
$applyCwd | boolean |
boolean
|
protected static resolveSymlink ($symlink) : string | bool
Resolves a symlink target.
Returns the resolved symlink path, or false
if it cannot be resolved.
Property | Type | Description |
---|---|---|
$symlink | mixed |
mixed
|
protected static withinOpenBaseDir (string $path) : bool
Checks if a given path is within "open_basedir" restrictions.
Property | Type | Description |
---|---|---|
$path | string |
string
|