PHPackages                             stein197/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. stein197/path

ActiveLibrary

stein197/path
=============

String paths abstraction

2.0.0(2y ago)17MITPHPPHP &gt;= 8.2

Since Apr 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/stein197/php-path)[ Packagist](https://packagist.org/packages/stein197/path)[ RSS](/packages/stein197-path/feed)WikiDiscussions main Synced 1w ago

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

PHP path class
==============

[](#php-path-class)

Provides a tiny class `Stein197\FileSystem\Path` that provides means to manage path strings easily.

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

[](#installation)

```
composer require stein197/path

```

Usage
-----

[](#usage)

The following code gives only a glipse of the available API provided by the package. The more detailed documentation can be found in the source code.

```
require __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

use Stein197\FileSystem\Path;

$p = Path::new('/var/www/html/project/public');

// Stringable interface implementation
(string) $p; // '/var/www/html/project/public'

// ArrayAccess interface implementation
isset($p[1]);   // true, it's 'var' part
$p[-2];         // 'project'
$p[3] = 'html'; // an exception, paths are read-only
unset($p[4]);   // an exception, paths are read-only

// Countable interface implementation
sizeof($p); // 5

// Iterator interface implementation
[...$p]; // ['', 'var', 'www', 'html', 'project', 'public']

// Stein197\Equalable interface implementation
$p->equals('\\var///www/html/project/public/'); // true

// Public readonly properties
$p->isDOS;      // false
$p->isUnix;     // true
$p->isRoot;     // false
$p->isAbsolute; // true
$p->isRelative; // false
$p->depth;      // 5
$p->drive;      // null; Valid only for DOS paths
$p->path;       // '/var/www/html/project/public'

// Dynamic methods
$p->getElement(1);                                        // 'var'; The same as $p[1]
$p->getParent();                                          // Path('/var/www/html/project')
$p->getSubpath(2, -2);                                    // Path('www/html/project')
$p->toAbsolute('/');                                      // Path('/var/www/html/project/public'); The path itself since it's already absolute
$p->toRelative('/var/www');                               // Path('html/project/public')
$p->format([
	'separator' => '\\',
	'trailingSlash' => true
]);                                                       // '\\var\\www\\html\\project\\public\\'
$p->startsWith('/var');                                   // true
$p->endsWith('public');                                   // true
$p->isChildOf('/var/www/html/project');                   // true
$p->isParentOf('/var/www/html/project/public/index.php'); // true
$p->includes('www/html');                                 // true
$p->firstIndexOf('www');                                  // 2
$p->lastIndexOf('public');                                // 5

// Static methods
Path::join('vendor', 'bin/phpunit');               // Path('vendor/bin/phpunit')
Path::expand('%SystemRoot%/Fonts');                // Path('C:\\Windows\\Fonts')
Path::normalize('/var////././www\\..\\www/html/'); // Path('/var/www/html')
Path::new('.');                                    // Path('.')
Path::findCommonBase(
	'/var/www/html',
	'/var/usr/bin'
);                                                 // Path('/var')
```

> For further information refer to the docblocks in the source code.

Composer scripts
----------------

[](#composer-scripts)

- `test` Run unit tests

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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

Every ~555 days

Total

2

Last Release

930d ago

Major Versions

1.0.0 → 2.0.02023-11-01

### Community

Maintainers

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

---

Top Contributors

[![stein197](https://avatars.githubusercontent.com/u/35802538?v=4)](https://github.com/stein197 "stein197 (132 commits)")

---

Tags

pathphp

###  Code Quality

TestsPest

### Embed Badge

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

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

PHPackages © 2026

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