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

ActiveLibrary

a4blue/path-util
================

A robust cross-platform utility for normalizing, comparing and modifying file paths.

1.0.0(4y ago)08MITPHPPHP ^7.3|~8.0|~8.1

Since Dec 8Pushed 4y agoCompare

[ Source](https://github.com/a4blue/path-util)[ Packagist](https://packagist.org/packages/a4blue/path-util)[ RSS](/packages/a4blue-path-util/feed)WikiDiscussions 1.x Synced 1mo ago

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

[![CI Pipeline](https://github.com/a4blue/path-util/actions/workflows/ci-pipeline.yml/badge.svg)](https://github.com/a4blue/path-util/actions/workflows/ci-pipeline.yml)

File Path Utility
=================

[](#file-path-utility)

PHP ^7.3|~8.0|~8.1

This package provides robust, cross-platform utility functions for normalizing, comparing and modifying file paths and URLs.

Motivation
----------

[](#motivation)

There are some Libraries that still use the original Code, which is deprecated, but don't want to switch to symfony/filesystem . In order to minimize Variations of the Code being copied to these Projects, i try to Hard-Fork the project and to maintain it, so that these can potentially use this library

Version 1 aims to be a drop-in replacement for webmozart/file-path

Usage
-----

[](#usage)

Use the `Path` class to handle file paths:

```
use A4blue\PathUtil\Path;

echo Path::canonicalize('/var/www/vhost/webmozart/../config.ini');
// => /var/www/vhost/config.ini

echo Path::canonicalize('C:\Programs\Webmozart\..\config.ini');
// => C:/Programs/config.ini

echo Path::canonicalize('~/config.ini');
// => /home/webmozart/config.ini

echo Path::makeAbsolute('config/config.yml', '/var/www/project');
// => /var/www/project/config/config.yml

echo Path::makeRelative('/var/www/project/config/config.yml', '/var/www/project/uploads');
// => ../config/config.yml

$paths = array(
    '/var/www/vhosts/project/httpdocs/config/config.yml',
    '/var/www/vhosts/project/httpdocs/images/banana.gif',
    '/var/www/vhosts/project/httpdocs/uploads/../images/nicer-banana.gif',
);

Path::getLongestCommonBasePath($paths);
// => /var/www/vhosts/project/httpdocs

Path::getFilename('/views/index.html.twig');
// => index.html.twig

Path::getFilenameWithoutExtension('/views/index.html.twig');
// => index.html

Path::getFilenameWithoutExtension('/views/index.html.twig', 'html.twig');
Path::getFilenameWithoutExtension('/views/index.html.twig', '.html.twig');
// => index

Path::getExtension('/views/index.html.twig');
// => twig

Path::hasExtension('/views/index.html.twig');
// => true

Path::hasExtension('/views/index.html.twig', 'twig');
// => true

Path::hasExtension('/images/profile.jpg', array('jpg', 'png', 'gif'));
// => true

Path::changeExtension('/images/profile.jpeg', 'jpg');
// => /images/profile.jpg

Path::join('phar://C:/Documents', 'projects/my-project.phar', 'composer.json');
// => phar://C:/Documents/projects/my-project.phar/composer.json

Path::getHomeDirectory();
// => /home/webmozart
```

Use the `Url` class to handle URLs:

```
use A4blue\PathUtil\Url;

echo Url::makeRelative('http://example.com/css/style.css', 'http://example.com/puli');
// => ../css/style.css

echo Url::makeRelative('http://cdn.example.com/css/style.css', 'http://example.com/puli');
// => http://cdn.example.com/css/style.css
```

Authors
-------

[](#authors)

- \[Bernhard Schussek\] a.k.a. [@webmozart](https://github.com/webmozarts) Original Author
- \[Alexander Ratajczak\] a.k.a. [@a4blue](https://github.com/a4blue)

Contribute
----------

[](#contribute)

Contributions are always welcome!

- Report any bugs or issues you find on the [issue tracker](https://github.com/a4blue/path-util/issues).
- You can grab the source code at the [Git repository](https://github.com/a4blue/path-util).

License
-------

[](#license)

All contents of this package are licensed under the MIT license.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.4% 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

1621d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35be0a3f4a7cc11fcb1dffac80a2a2cf6f8e9162294ee36c9dd4230321320e51?d=identicon)[a4blue](/maintainers/a4blue)

---

Top Contributors

[![webmozart](https://avatars.githubusercontent.com/u/176399?v=4)](https://github.com/webmozart "webmozart (91 commits)")[![SenseException](https://avatars.githubusercontent.com/u/859964?v=4)](https://github.com/SenseException "SenseException (18 commits)")[![a4blue](https://avatars.githubusercontent.com/u/1339417?v=4)](https://github.com/a4blue "a4blue (8 commits)")[![King2500](https://avatars.githubusercontent.com/u/4896363?v=4)](https://github.com/King2500 "King2500 (8 commits)")[![DavidBadura](https://avatars.githubusercontent.com/u/470138?v=4)](https://github.com/DavidBadura "DavidBadura (4 commits)")[![hason](https://avatars.githubusercontent.com/u/288535?v=4)](https://github.com/hason "hason (1 commits)")[![h4cc](https://avatars.githubusercontent.com/u/2981491?v=4)](https://github.com/h4cc "h4cc (1 commits)")[![tgalopin](https://avatars.githubusercontent.com/u/1651494?v=4)](https://github.com/tgalopin "tgalopin (1 commits)")[![harikt](https://avatars.githubusercontent.com/u/120454?v=4)](https://github.com/harikt "harikt (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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