Download the PHP package als/path without Composer
On this page you can find all versions of the php package als/path. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package path
Short Description Path Component.
License MIT
Homepage https://github.com/parser3/als.path
Informations about the package path
Als/Path
Path Component.
Documentations
Properties
- $delimiter
- $separator
- $cwd
Methods
- @basename
- @dirname
- @extname
- @format
- @isAbsolute
- @join
- @normalize
- @parse
- @relative
- @resolve
$PROPERTY: delimiter
Provides the path delimiter.
Example
$PROPERTY: separator
Provides the path segment separator.
Example
$PROPERTY: cwd
Contains the absolute path of the 'DOCUMENT_ROOT'.
Example
@METHOD: basename
The ^Als/Path:basename[]
methods returns the last portion of a path
, similar to the Unix basename
command.
Syntax
^Als/Path:basename[path[;ext]]
Params
- $path
<string>
- $ext
<string>
An optional file extension.
Example
@METHOD: dirname
The ^Als/Path:dirname[]
method returns the directory name of a path
, similar to the Unix dirname
command.
Syntax
^Als/Path:dirname[path]
Params
- $path
<string>
Example
@METHOD: extname
The ^Als/Path:extname[]
method returns the extension of the path
, from the last occurance of the .
(period) character to end of string in the last portion of the path
. If there is no .
in the last portion of the path
, or if the first character of the basename of path
(see ^Als/Path:basename[]
) is .
, then an empty string is returned.
Syntax
^Als/Path:extname[path]
Params
- $path
<string>
Example
@METHOD: format
The ^Als/Path:format[]
method returns a path string from an <hash>
. This is the opposite of ^Als/Path:parse[]
.
Syntax
^Als/Path:format[hPath]
Params
- $hPath
<hash>
- $.dir
<string>
- $.root
<string>
- $.base
<string>
- $.name
<string>
- $.ext
<string>
- $.dir
The following process is used when constructing the path string:
$result
is set to an empty string.- If
$.dir[]
is specified,$.dir[]
is appended to$result
followed by the value of$Als/Path:separator
; - Otherwise, if
$.root[]
is specified,$.root[]
is appended to$result
. - If
$.base[]
is specified,$.base[]
is appended to$result
; - Otherwise:
- If
$.name[]
is specified,$.name[]
is appended to$result
- If
$.ext[]
is specified,$.ext[]
is appended to$result
.
- If
- Return
$result
Example
@METHOD: isAbsolute
The ^Als/Path:isAbsolute[]
method determines if path
is an absolute path.
If the given path
is a zero-length string, false
will be returned.
Syntax
^Als/Path:isAbsolute[path]
Params
- path
<string>
Example
@METHOD: join
The ^Als/Path:join[]
method join all given path
segments together using the @normalizes the resulting path.
Zero-length path
segments are ignored. If the joined path string is a zero-length string then '.'
will be returned, representing the current working directory.
Syntax
^Als/Path:join[path1;path2[;...]]
Params
- path[, ...]
<string>
A sequence of path segments.
Example
@METHOD: normalize
The ^Als/Path:normalize[]
method normalizes the given path
, resolving '..'
and '.'
segments.
When multiple, sequential path segment separation characters are found, they are replaced by a single instance of the path segment separator. Trailing separators are preserved.
If the path is a zero-length string, '.'
is returned, representing the current working directory.
Syntax
^Als/Path:normalize[path]
Params
- path
<string>
Example
@METHOD: parse
The ^Als/Path:parse[]
method returns an <hash>
whose properties represent significant elements of the path.
The returned <hash>
will have the following properties:
- $.root
<string>
- $.dir
<string>
- $.base
<string>
- $.ext
<string>
- $.name
<string>
Syntax
^Als/Path:parse[path]
Params
- path
<string>
Example
@METHOD: relative
The ^Als/Path:relative[]
method returns the relative path from from
to to
. If from
and to
each resolve to the same path (after calling ^Als/Path:resolve[]
on each), a zero-length string is returned.
If a zero-length string is passed as from
or to
, the current working directory will be used instead of the zero-length strings.
Syntax
^Als/Path:relative[from;to]
Params
- from
<string>
- to
<string>
Example
@METHOD: resolve
The ^Als/Path:resolve[]
method resolves a sequence of paths or path segments into an absolute path.
The given sequence of paths is processed from right to left, with each subsequent path
prepended until an absolute path is constructed. For instance, given the sequence of path segments: /foo
, /bar
, baz
, calling ^Als/Path:resolve[/foo;/bar;baz]
would return /bar/baz
.
If after processing all given path
segments an absolute path has not yet been generated, the current working directory is used.
The resulting path is normalized and trailing slashes are removed unless the path is resolved to the root directory.
Zero-length path
segments are ignored.
If no path
segments are passed, ^Als/Path:resolve[]
will return the absolute path of the current working directory.
Syntax
^Als/Path:resolve[[path[; ...]]
Params
- path[, ...]
<string>
A sequence of paths or path segments
Example
References
- Questions to Leonid Knyazev [email protected]
- Bug reports and Feature requests to Issues.