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

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

czproject/path-helper
=====================

Helper class for creating relative paths, absolutizing, etc.

v4.2.0(1y ago)313.1k↓84.6%5BSD-3-ClausePHPPHP 8.0 - 8.4CI passing

Since Mar 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/czproject/path-helper)[ Packagist](https://packagist.org/packages/czproject/path-helper)[ Fund](https://www.janpecha.cz/donate/)[ RSS](/packages/czproject-path-helper/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (1)Versions (7)Used By (5)

CzProject\\PathHelper
=====================

[](#czprojectpathhelper)

[![Build Status](https://github.com/czproject/path-helper/workflows/Build/badge.svg)](https://github.com/czproject/path-helper/actions)[![Downloads this Month](https://camo.githubusercontent.com/9a66af30cd6f3d300289322d8adc8a7f7d63aa34659fc9f89ff8a21556e959e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f637a70726f6a6563742f706174682d68656c7065722e737667)](https://packagist.org/packages/czproject/path-helper)[![Latest Stable Version](https://camo.githubusercontent.com/a52be6f1c6668e441186f6f780e01183eec277587422531fb0167aaf12616de6/68747470733a2f2f706f7365722e707567782e6f72672f637a70726f6a6563742f706174682d68656c7065722f762f737461626c65)](https://github.com/czproject/path-helper/releases)[![License](https://camo.githubusercontent.com/fa7d5fcf2c84b580327af52da95dd751703af65f079dc3c5a0081beac0789718/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4e65772532304253442d626c75652e737667)](https://github.com/czproject/path-helper/blob/master/license.md)

Helper class for creating relative paths, absolutizing paths,...

[![Donate](https://camo.githubusercontent.com/101b981194f1dafbf9c42e19c3034fe2d724e75be972cef0f4477074997834db/68747470733a2f2f6275796d65636f666665652e696e746d2e6f72672f696d672f646f6e6174652d62616e6e65722e76312e737667)](https://www.janpecha.cz/donate/)

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

[](#installation)

[Download a latest package](https://github.com/czproject/path-helper/releases) or use [Composer](http://getcomposer.org/):

```
composer require czproject/path-helper

```

Library requires PHP 8.0 or later.

Usage
-----

[](#usage)

```
use CzProject\PathHelper;
```

### Absolutize path

[](#absolutize-path)

```
PathHelper::absolutizePath($path);

PathHelper::absolutizePath('path/to/my/../text/./file.txt');
```

Returns `/path/to/text/file.txt`

You can use second parameter `$prefix`:

```
PathHelper::absolutizePath('path/to/my/../text/./file.txt', NULL); // returns path/to/text/file.txt
PathHelper::absolutizePath('path/to/my/../text/./file.txt', '/file/root/'); // returns /file/root/path/to/text/file.txt
```

### Creating relative path

[](#creating-relative-path)

```
$source = 'root/dir/docs/1.0/index.html';
$dest = 'root/dir/imgs/image.jpg';

PathHelper::createRelativePath($source, $dest);
```

Returns `../../imgs/image.jpg`

### Is path current?

[](#is-path-current)

```
PathHelper::isPathCurrent($path, $mask);

PathHelper::isPathCurrent('dir/file.txt', 'dir/file-2.txt'); // returns FALSE
PathHelper::isPathCurrent('dir/file.txt', 'dir/*'); // returns TRUE
PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/*'); // returns FALSE
PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/*/*'); // returns TRUE
PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/**'); // returns TRUE
```

MaskMeaning`**`means *everything*`*`means *everything **except** `/`*### Normalize path

[](#normalize-path)

Normalizes path delimiters to `/`.

```
PathHelper::normalizePath($path);

PathHelper::normalizePath('\\path\\to\\file.txt');
```

Returns `/path/to/file.txt`.

### Helper instance

[](#helper-instance)

```
$helper = new CzProject\PathHelper;
$helper->absolutizePath('/path/to/to/../file');
$helper->createRelativePath('/path/to/file', '/path/to');
$helper->isPathCurrent('/path/file', '/path/*');
```

---

License: [New BSD License](license.md)
Author: Jan Pecha,

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance48

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

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

Recently: every ~901 days

Total

6

Last Release

387d ago

Major Versions

v1.0.0 → v2.0.02015-07-27

v2.0.0 → v3.0.02015-09-04

v3.0.0 → v4.0.02015-12-23

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.0

v4.2.0PHP 8.0 - 8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c980b1511b4a0350442dc23d89c99d4d9a2411b7e765d52c133ccacf616968b?d=identicon)[janpecha](/maintainers/janpecha)

---

Top Contributors

[![janpecha](https://avatars.githubusercontent.com/u/637719?v=4)](https://github.com/janpecha "janpecha (44 commits)")

---

Tags

absolute-pathsphp

### Embed Badge

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

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

###  Alternatives

[suin/php-rss-writer

Yet another simple RSS writer library for PHP 5.4 or later.

2831.4M21](/packages/suin-php-rss-writer)[topshelfcraft/environment-label

...so you don't forget where you are.

16234.7k12](/packages/topshelfcraft-environment-label)

PHPackages © 2026

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