PHPackages                             ama-team/pathetic - 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. ama-team/pathetic

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

ama-team/pathetic
=================

A small library that helps in dealing with paths

0.1.1(9y ago)345MITPHPPHP &gt;= 5.4

Since May 31Pushed 9y ago2 watchersCompare

[ Source](https://github.com/ama-team/pathetic)[ Packagist](https://packagist.org/packages/ama-team/pathetic)[ RSS](/packages/ama-team-pathetic/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (5)Used By (0)

Pathetic
========

[](#pathetic)

[![Packagist](https://camo.githubusercontent.com/3533aa683ef30439b5dcb1aaebf1d92a3b81b170a3e578c61f4d93ad6d092da7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616d612d7465616d2f70617468657469632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ama-team/pathetic)[![AppVeyor/Master](https://camo.githubusercontent.com/86ddb3025c7a7f44394ca7f3962a2316e9279850b672f919cdf40284f94dfd89/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f65746b692f70617468657469632f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://ci.appveyor.com/project/etki/pathetic)[![CircleCI/Master](https://camo.githubusercontent.com/fe95bb1c9ffeb1e03a0454dcc1d9ae71e9fd7eb2f09f35988a4503c6d3860e2a/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f6769746875622f616d612d7465616d2f70617468657469632f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://circleci.com/gh/ama-team/pathetic/tree/master)[![Scrutinizer/Master](https://camo.githubusercontent.com/96fce4b57cfa1b4e4bc643d01303422fc860cb354c06d0f368a36a65faf71eaa/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616d612d7465616d2f70617468657469632f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ama-team/pathetic?branch=master)[![Coveralls/Master](https://camo.githubusercontent.com/5838c0b54229e1d357a469bbe80da1258a6028c56ddf688c9febc6d4f8139513/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f616d612d7465616d2f70617468657469632f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/ama-team/pathetic?branch=master)

Pathetic is a simple PHP library consisting just of couple of classes. It is aimed to help with platform-independent path work, so you can run the same code, fnmatch checks and comparisons regardless of specific machine your project is running on.

And yes, it is influenced by `java.nio.Path`.

Installation
------------

[](#installation)

```
composer require ama-team/pathetic
```

Usage
-----

[](#usage)

You start with classic string and `Path::parse` method:

```
use AmaTeam\Pathetic\Path;

$path = Path::parse('beverages/soda');
$path = Path::parse('file://beverages/soda');
$path = Path::parse('c:\\beverages\\soda', Path::PLATFORM_WINDOWS);
$path = Path::parse('c:/beverages/soda', Path::PLATFORM_WINDOWS);
$path = Path::parse('custom-scheme://c:/beverages/soda', Path::PLATFORM_WINDOWS);
```

Second argument should be used only when you operate with paths for specific platform - by default, it is calculated automatically.

After you've obtained path instance, you can simply convert it to string to get consistent-delimiter representation:

```
$path = Path::parse('file://beverages\\soda');
echo (string) $path; // file://beverages/soda
```

This will save you from awkward moments when you append `directory/file` to windows path and then try to compare it with path received from OS (which will contain `directory\file` instead), also, it makes it pretty easy to use `fnmatch` glob patterns platform-independently.

If you ever to need platform-consistent representation, you may use `toPlatformString()` method:

```
echo $path->toPlatformString(); // file://beverages\\soda
```

Except for those basic operations, Pathetic allows basic path normalization, path concatenation (resolution), path relativization and path comparison.

```
$path = Path::parse('/node/directory//./../leaf');
echo (string) $path; # /node/directory//./../leaf
echo $path->normalize(); # /node/leaf
$path->isAbsolute(); # true

$node = Path::parse('/node');
$leaf = Path::parse('leaf');
$other = $node->resolve($leaf); # /node/leaf
$path->isChildOf($node); # true
$path->isSiblingOf($other); # true
$path->equals($other); # true
echo (string) $path->getParent(); # /node
echo (string) $node->relativize($path); # leaf
foreach ($path->iterator() as $entry) {
    echo (string) $entry;
    # /
    # /node
    # /node/leaf
}
```

At last, there are some helper methods you may want to use:

```
$path = Path::parse('file://c:/node/directory', Path::PLATFORM_WINDOWS);
$path = $path->withoutScheme()->withRoot('d:');
echo $path->getRoot(); # d:
echo $path->getScheme(); # null
echo $path->getSeparator(); # \ - because of windows platform
```

### Major notes

[](#major-notes)

All path operations are non-destructive, and all path instances are immutable - whenever `#normalize()`, `#relativize()` or `#withRoot()`are called, new object is created instead of modifying old one.

There is edge case with current directory - while one may expect that normalized relative path of current directory will render down to dot (`'.'`), this won't happen - it will be rendered to empty string (`''`). However, while you don't call for normalization, your path will stay as-is.

Windows has two types of absolute paths - with and without drive letter, (`\Users` and `C:\Users`, for example). Both types are treated as absolute by Pathetic - it's up to end user to determine if he or she has to specify drive letter to not to inherit it from current working directory. This is, of course, a drawback, but unless that absolute path is inherited from user input - which should be intentional thing - that shouldn't happen.

### Dev branch shield cellar

[](#dev-branch-shield-cellar)

[![AppVeyor/Dev](https://camo.githubusercontent.com/8956c4fa82a8aa46e3f758b28640d35ee00291bb885cdb4b92aa61ae13206ef0/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f65746b692f70617468657469632f6465762e7376673f7374796c653d666c61742d737175617265)](https://ci.appveyor.com/project/etki/pathetic)[![CircleCI/Dev](https://camo.githubusercontent.com/6c5266679004246360de11a40a5c584a1b599b77da2fd2aa1c80d6fa4839f3e3/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f6769746875622f616d612d7465616d2f70617468657469632f6465762e7376673f7374796c653d666c61742d737175617265)](https://circleci.com/gh/ama-team/pathetic/tree/dev)[![Scrutinizer/Dev](https://camo.githubusercontent.com/977e05b4f3ff71bc73f4f27a7852692317b41d0c5efb01f94a3564cd9f52b7e1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616d612d7465616d2f70617468657469632f6465762e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ama-team/pathetic/?branch=dev)[![Coveralls/Dev](https://camo.githubusercontent.com/2fd1d988d09ffc958669229571fa3196f6a4ca8cf7caaf7fc01d6bb5fb837c88/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f616d612d7465616d2f70617468657469632f6465762e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/ama-team/pathetic?branch=dev)

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

Every ~0 days

Total

2

Last Release

3317d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1909762?v=4)[Etki](/maintainers/etki)[@etki](https://github.com/etki)

---

Top Contributors

[![etki](https://avatars.githubusercontent.com/u/1909762?v=4)](https://github.com/etki "etki (15 commits)")

---

Tags

pathpathsphp

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/ama-team-pathetic/health.svg)

```
[![Health](https://phpackages.com/badges/ama-team-pathetic/health.svg)](https://phpackages.com/packages/ama-team-pathetic)
```

PHPackages © 2026

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