PHPackages                             als/path - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. als/path

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

als/path
========

Path Component.

1.0.0(9y ago)01261MITOpenEdge ABL

Since Dec 1Pushed 9y agoCompare

[ Source](https://github.com/parser3/als.path)[ Packagist](https://packagist.org/packages/als/path)[ Docs](https://github.com/parser3/als.path)[ RSS](/packages/als-path/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Als/Path
========

[](#alspath)

Path Component.

---

Documentations
--------------

[](#documentations)

### Properties

[](#properties)

- [$delimiter](#property-delimiter)
- [$separator](#property-separator)
- [$cwd](#property-cwd)

---

### Methods

[](#methods)

- [@basename](#method-basename)
- [@dirname](#method-dirname)
- [@extname](#method-extname)
- [@format](#method-format)
- [@isAbsolute](#method-isAbsolute)
- [@join](#method-join)
- [@normalize](#method-normalize)
- [@parse](#method-parse)
- [@relative](#method-relative)
- [@resolve](#method-resolve)

---

$PROPERTY: delimiter
--------------------

[](#property-delimiter)

Provides the path delimiter.

---

#### Example

[](#example)

```
${Als/Path:delimiter}
#--> ':'

$env:PATH
#--> '/usr/local/bin:/usr/bin:/bin'

$paths[^env:PATH.split[${Als/Path:delimiter};h]]
#--> |/usr/local/bin|/usr/bin|/bin|
```

---

$PROPERTY: separator
--------------------

[](#property-separator)

Provides the path segment separator.

---

#### Example

[](#example-1)

```
${Als/Path:separator}
#--> '/'

$path[/assets/images/icons.png]
$parts[^path.split[${Als/Path:separator};h]]
#--> |assets|images|icons.png|
```

---

$PROPERTY: cwd
--------------

[](#property-cwd)

Contains the absolute path of the 'DOCUMENT\_ROOT'.

---

#### Example

[](#example-2)

```
${Als/Path:cwd}
#--> '/home/username/host/www'
```

---

---

@METHOD: basename
-----------------

[](#method-basename)

The `^Als/Path:basename[]` methods returns the last portion of a `path`, similar to the Unix `basename` command.

---

### Syntax

[](#syntax)

`^Als/Path:basename[path[;ext]]`

### Params

[](#params)

- $path ``
- $ext `` An optional file extension.

### Example

[](#example-3)

```
^Als/Path:basename[/foo/bar/baz/asdf/quux.html]
#--> 'quux.html'

^Als/Path:basename[/foo/bar/baz/asdf/quux.html;.html]
#--> 'quux'
```

---

@METHOD: dirname
----------------

[](#method-dirname)

The `^Als/Path:dirname[]` method returns the directory name of a `path`, similar to the Unix `dirname` command.

---

### Syntax

[](#syntax-1)

`^Als/Path:dirname[path]`

### Params

[](#params-1)

- $path ``

### Example

[](#example-4)

```
^Als/Path:dirname[/foo/bar/baz/asdf/quux]
#--> '/foo/bar/baz/asdf'
```

---

@METHOD: extname
----------------

[](#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[]`](#method-basename)) is `.`, then an empty string is returned.

---

### Syntax

[](#syntax-2)

`^Als/Path:extname[path]`

### Params

[](#params-2)

- $path ``

### Example

[](#example-5)

```
^Als/Path:extname[index.html]
#--> '.html'

^Als/Path:extname[index.coffee.md]
#--> '.md'

^Als/Path:extname[index.]
#--> '.'

^Als/Path:extname[index]
#--> ''

^Als/Path:extname[.index]
#--> ''
```

---

@METHOD: format
---------------

[](#method-format)

The `^Als/Path:format[]` method returns a path string from an ``. This is the opposite of [`^Als/Path:parse[]`](#method-parse).

---

### Syntax

[](#syntax-3)

`^Als/Path:format[hPath]`

### Params

[](#params-3)

- $hPath ``
    - $.dir ``
    - $.root ``
    - $.base ``
    - $.name ``
    - $.ext ``

---

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`](#property-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`.
- Return `$result`

### Example

[](#example-6)

```
# If 'dir' and 'base' are provided:
# ${dir}${separator}${base}
# will be returned.
^Als/Path:format[
	$.dir[/home/user/dir]
	$.base[file.txt]
]
//--> '/home/user/dir/file.txt'

# 'root will be used if 'dir' is not specified.
# If only 'root' is provided or 'dir' is equal to 'root'
# then the separator will not be included.
^Als/Path:format[
	$.root[/]
	$.base[file.txt]
]
#--> '/file.txt'

# `name` + `ext` will be used if `base` is not specified.
^Als/Path:format[
	$.root[/]
	$.name[file]
	$.ext[.txt]
]
#--> '/file.txt'

# `base` will be returned if `dir` or `root` are not provided.
^Als/Path:format[
	$.base[file.txt]
]
#--> 'file.txt'
```

---

@METHOD: isAbsolute
-------------------

[](#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

[](#syntax-4)

`^Als/Path:isAbsolute[path]`

### Params

[](#params-4)

- path ``

### Example

[](#example-7)

```
^Als/Path:isAbsolute[/foo/bar]
#--> true

^Als/Path:isAbsolute[/baz/..]
#--> true

^Als/Path:isAbsolute[qux/]
#--> false

^Als/Path:isAbsolute[.]
#--> false
```

---

@METHOD: join
-------------

[](#method-join)

The `^Als/Path:join[]` method join all given `path` segments together using the [`$Als/Path:separator`](#property-separator) as a delimiter, then [@normalize](#method-normalize)s 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

[](#syntax-5)

`^Als/Path:join[path1;path2[;...]]`

### Params

[](#params-5)

- path\[, ...\] `` A sequence of path segments.

### Example

[](#example-8)

```
^Als/Path:join[/foo;bar;baz/asdf;quux;..]
#--> '/foo/bar/baz/asdf'

^Als/Path:join[foo; $.path[123] ;bar]
#--> throws 'invalid.argument' error.
```

---

@METHOD: normalize
------------------

[](#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

[](#syntax-6)

`^Als/Path:normalize[path]`

### Params

[](#params-6)

- path ``

### Example

[](#example-9)

```
^Als/Path:normalize[/foo/bar//baz/asdf/quux/..]
#--> '/foo/bar/baz/asdf'
```

---

@METHOD: parse
--------------

[](#method-parse)

The `^Als/Path:parse[]` method returns an `` whose properties represent significant elements of the path.

The returned `` will have the following properties:

- $.root ``
- $.dir ``
- $.base ``
- $.ext ``
- $.name ``

---

### Syntax

[](#syntax-7)

`^Als/Path:parse[path]`

### Params

[](#params-7)

- path ``

### Example

[](#example-10)

```
^Als/Path:parse[/home/user/dir/file.txt]
#-->
#  $.root[/]
#  $.dir[/home/user/dir]
#  $.base[file.txt]
#  $.ext[.txt]
#  $.name[file]
```

---

@METHOD: relative
-----------------

[](#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[]`](#method-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

[](#syntax-8)

`^Als/Path:relative[from;to]`

### Params

[](#params-8)

- from ``
- to ``

### Example

[](#example-11)

```
^Als/Path:relative[/home/user/test/aaa;/home/user/impl/bbb]
#--> '../../impl/bbb'
```

---

@METHOD: resolve
----------------

[](#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

[](#syntax-9)

`^Als/Path:resolve[[path[; ...]]`

### Params

[](#params-9)

- path\[, ...\] `` A sequence of paths or path segments

### Example

[](#example-12)

```
^Als/Path:resolve[/foo/bar;./baz]
#--> '/foo/bar/baz'

^Als/Path:resolve[/foo/bar;/tmp/file/]
#--> '/tmp/file'

# if the current working directory is '/home/myself/node'
^Als/Path:resolve[wwwroot;static_files/png/;../gif/image.gif]
#--> '/home/myself/node/wwwroot/static_files/gif/image.gif'
```

---

---

References
----------

[](#references)

- Questions to Leonid Knyazev  |
- Bug reports and Feature requests to Issues.

---

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3456d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e183c32f930a49fa36f0f7f6af0ff24e3fa0c0977f412dc1fba10743eee15426?d=identicon)[knyazev](/maintainers/knyazev)

---

Top Contributors

[![leokn](https://avatars.githubusercontent.com/u/398527?v=4)](https://github.com/leokn "leokn (9 commits)")

---

Tags

alspackageparser3pathals

### Embed Badge

![Health badge](/badges/als-path/health.svg)

```
[![Health](https://phpackages.com/badges/als-path/health.svg)](https://phpackages.com/packages/als-path)
```

###  Alternatives

[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[matthiasmullie/path-converter

Relative path converter

10229.6M7](/packages/matthiasmullie-path-converter)[sebastianfeldmann/camino

Path management the OO way

176.4M1](/packages/sebastianfeldmann-camino)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
