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

ActiveLibrary

xakepehok/path
==============

Util for filesystem path navigation

0.2.7(2y ago)19.0kBSD-3-ClausePHPPHP &gt;=7.2.0

Since Feb 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/XAKEPEHOK/Path)[ Packagist](https://packagist.org/packages/xakepehok/path)[ RSS](/packages/xakepehok-path/feed)WikiDiscussions master Synced today

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

Path [![Build Status](https://camo.githubusercontent.com/1038f51396220ff1370ae415b827b6ba3cd478c2cc43a0dbcda4efc04a11dd77/68747470733a2f2f7472617669732d63692e636f6d2f58414b455045484f4b2f506174682e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/XAKEPEHOK/Path)
==============================================================================================================================================================================================================================================================================

[](#path-)

Path class help you easy manipulate to any path (unix-style, windows-style, uri path), going up and down, extract last path item, detect project root and more. This lib not work with file system. Its just help you manipulate path string.

### Installation:

[](#installation)

```
composer require xakepehok/path
```

Path manipulation
-----------------

[](#path-manipulation)

### Unix-style path:

[](#unix-style-path)

```
# Create path object with some path and define path separator.
# If separator not defined, it will be detected from passed path string
$path = new \XAKEPEHOK\Path\Path('/any/path/here');

# /any/path
echo $path->up();

# /any/path/here/down_1/down_2
echo $path->down('down_1')->down('down_2');

# Ending or double slashes will be removed
# /any/path/here/down_1/down_2
echo $path->down('/down_1/')->down('/down_2/');

# Empty down will be ignored
# /any/path/here
echo $path->down('');

# /any/path/here/down_1/down_2
echo $path->down('down_1/down_2');

# Backslash will be replaced by slash, because path already contain slash
# /any/path/here/down_1/down_2
echo $path->down('down_1\down_2');

$subPath = new \XAKEPEHOK\Path\Path('dir_1/dir_2')

# /any/path/here/dir_1/dir_2
echo $path->down($subPath);

# /any/path/down_1/dir_1/dir_2
echo $path->up()->down('down_1/down_2')->up()->down($subPath);
```

### Windows-style path:

[](#windows-style-path)

```
$path = new \XAKEPEHOK\Path\Path('C:\\Windows');

# C:\
echo $path->up();

# C:\Windows\System32\drivers
echo $path->down('System32')->down('drivers');

# Ending or double backslashes will be removed
# C:\Windows\System32\drivers
echo $path->down('\\System32\\')->down('\\drivers\\');

# C:\Windows\System32\drivers
echo $path->down('System32\drivers');

# Slash will be replaced by backslash, because path already contain backslash
# C:\Windows\System32\drivers\etc
echo $path->down('System32/drivers\etc');

$subPath = new \XAKEPEHOK\Path\Path('Adobe/Photoshop')

# C:\Windows\System32\drivers
echo $path->down($subPath);

# C:\Program Files\Adobe\Photoshop
echo $path->up()->down('Program Files\\Microsoft')->up()->down($subPath);
```

### Uri path (works like unix-style path):

[](#uri-path-works-like-unix-style-path)

```
$path = new \XAKEPEHOK\Path\Path('https://example.com/path');

# https://example.com
echo $path->up();

# https://example.com/path/dir_1/dir_2
echo $path->down('dir_1')->down('dir_2');

# https://example.com/path/down_1/down_2
echo $path->down('down_1/down_2');

# Backslash will be replaced by slash, because path already contain slash
# https://example.com/path/down_1/down_2
echo $path->down('down_1\down_2');

$subPath = new \XAKEPEHOK\Path\Path('dir_1/dir_2')
```

### End of path

[](#end-of-path)

```
$path = new \XAKEPEHOK\Path\Path('/etc/nginx/nginx.conf');

# Return FileName object
$filename = $path->end();

# nginx
echo $filename->getName(false); //without extension

# nginx.conf
echo $filename->getName(true); //with extension

# conf
echo $filename->getExtension(); //extension

# true
echo $filename->hasExtension(); //bool true if file has extension
```

Detect project root path
------------------------

[](#detect-project-root-path)

```
# Return you project root path (dir that contain composer's vendor dir).
# Its detected by reflection of \Composer\Autoload\ClassLoader.php placement
$path = \XAKEPEHOK\Path\Path::root();
```

###  Health Score

27

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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 ~158 days

Total

10

Last Release

801d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2175cd00cb8574f68cb4a56a79af13410e31b9f6279d637bcea8d2470ed70b2a?d=identicon)[XAKEPEHOK](/maintainers/XAKEPEHOK)

---

Tags

pathutilnavaigation

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/uri-components

URI components manipulation library

31830.1M52](/packages/league-uri-components)[matthiasmullie/path-converter

Relative path converter

10128.7M7](/packages/matthiasmullie-path-converter)[galbar/jsonpath

JSONPath implementation for querying and updating JSON objects

2106.2M54](/packages/galbar-jsonpath)[sebastianfeldmann/camino

Path management the OO way

176.2M](/packages/sebastianfeldmann-camino)[jansenfelipe/utils

Uma simples classe utilitária com métodos que podem salvar sua vida (ou não)

66144.1k10](/packages/jansenfelipe-utils)[middlewares/trailing-slash

Middleware to normalize the trailing slash of the uri path

32495.2k10](/packages/middlewares-trailing-slash)

PHPackages © 2026

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