PHPackages                             neunerlei/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. neunerlei/path-util

Abandoned → [neunerlei/filesystem](/?search=neunerlei%2Ffilesystem)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

neunerlei/path-util
===================

FORKED: A robust cross-platform utility for normalizing, comparing and modifying file paths, with extended functionality.

2.4.0(6y ago)02.1k3MITPHPPHP ^7.3

Since Nov 26Pushed 3y agoCompare

[ Source](https://github.com/Neunerlei/path-util)[ Packagist](https://packagist.org/packages/neunerlei/path-util)[ RSS](/packages/neunerlei-path-util/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (13)Used By (3)

ABANDONED / DEPRECATED
----------------------

[](#abandoned--deprecated)

To follow the approach of webmozart/path-util I merged the path functionallity into [neunerlei/filesystem](https://github.com/Neunerlei/filesystem#path-utility), which should be used in the future as I see this repository as deprecated. I did not migrate the "makeUri" method into the filesystem bundle, as it is not really related to "filesystem" actions. So, you have to create an alternative for that yourself by using the Leage/Uri component directly.

File Path Utility (FORKED)
==========================

[](#file-path-utility-forked)

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

**ATTENTION: This is a fork of [path-util](https://github.com/webmozart/path-util) by [webmozart](https://github.com/webmozart)!**

`PHP >= 7.3.0`

What's different?
-----------------

[](#whats-different)

- Removed "Url" utility and replaced it with [URI by PHP League](https://uri.thephpleague.com/)
- Added new methods to the Path class
- Added tests for the new methods
- Updated PHP dependency to 7.3.0
- Updated existing code to use PHP Type Hints
- Updated tests to work with the modified code (Mostly to support the Type Hints)
- Removed dependency on "webmozart/assert"
- The Path class is no longer a "final" class
- All private methods of the Path class are now "protected"
- Removed build related files

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

[](#installation)

The utility can be installed with [Composer](https://getcomposer.org):

```
$ composer require neunerlei/path-util

```

Basic Usage
-----------

[](#basic-usage)

Use the `Path` class to handle file paths:

```
use Neunerlei\PathUtil\Path;

// These methods are added by this fork
// ==========================================================
echo Path::unifySlashes("\\foo/bar\\baz");
// => /foo/bar/baz (on linux) or \foo\bar\baz (on windows)

echo Path::unifyPath("\\foo/bar\\baz");
// => /foo/bar/baz/ (on linux) or \foo\bar\baz\ (on windows)

echo Path::classBasename(\Neunerlei\PathUtil\Path::class);
// => Path

echo Path::classNamespace(\Neunerlei\PathUtil\Path::class);
// => Neunerlei\PathUtil

$link = Path::makeUri();
// => Returns a new Uri object -> See "URI" Section for details.

// Those methods were already in the base implementation
// ==========================================================
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
```

URI handling
------------

[](#uri-handling)

When using the `Path::makeLink()` method you can supply a single parameter that will be used as a base for the generated link object. Possible parameter options are:

- string: A url represented by a string
- instance: An object that implements \\League\\Uri\\Contracts\\UriInterface or Psr\\Http\\Message\\UriInterface
- TRUE: Let the script figure out the url based on the current $\_SERVER super-global
- array: The result of parse\_url() or a similarly constructed array

If no parameter is given an empty Uri object is returned. The method uses the [League\\Uri](https://uri.thephpleague.com/uri/6.0/) package under the hood. The result of the method is an instance of a [PSR-7](https://www.php-fig.org/psr/psr-7/) compliant URI object.

Base Package documentation
--------------------------

[](#base-package-documentation)

Learn more about the forked **base package** in the [Documentation](https://github.com/webmozart/path-util/docs/usage.md).

Authors
-------

[](#authors)

- [Bernhard Schussek](http://webmozarts.com) a.k.a. [@webmozart](https://twitter.com/webmozart)
- [The Community Contributors](https://github.com/neunerlei/path-util/graphs/contributors)
- [Martin Neundorfer](https://www.neunerlei.eu)

Contribute
----------

[](#contribute)

Contributions are always welcome!

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

License
-------

[](#license)

All contents of this package are licensed under the [MIT license](LICENSE).

Special Thanks
--------------

[](#special-thanks)

Special thanks goes to the folks at [LABOR.digital](https://labor.digital/) (which is the word german for laboratory and not the english "work" :D) for making it possible to publish my code online.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment I highly appreciate you sending me a postcard from your hometown, mentioning which of our package(s) you are using.

You can find my address [here](https://www.neunerlei.eu/).

Thank you :D

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 71.8% 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 ~174 days

Recently: every ~413 days

Total

12

Last Release

2267d ago

Major Versions

1.1.0 → 2.0.02015-05-21

PHP version history (2 changes)1.0.0PHP &gt;=5.3.3

2.4.0PHP ^7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0eb1c26fb5a535cd7a656faffbae7929009558b2bfa6156b2be7b636d689e13a?d=identicon)[labor-digital](/maintainers/labor-digital)

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

---

Top Contributors

[![webmozart](https://avatars.githubusercontent.com/u/176399?v=4)](https://github.com/webmozart "webmozart (89 commits)")[![SenseException](https://avatars.githubusercontent.com/u/859964?v=4)](https://github.com/SenseException "SenseException (18 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)")[![Neunerlei](https://avatars.githubusercontent.com/u/22350956?v=4)](https://github.com/Neunerlei "Neunerlei (1 commits)")[![harikt](https://avatars.githubusercontent.com/u/120454?v=4)](https://github.com/harikt "harikt (1 commits)")[![tgalopin](https://avatars.githubusercontent.com/u/1651494?v=4)](https://github.com/tgalopin "tgalopin (1 commits)")[![h4cc](https://avatars.githubusercontent.com/u/2981491?v=4)](https://github.com/h4cc "h4cc (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[scssphp/scssphp

scssphp is a compiler for SCSS written in PHP.

62827.7M220](/packages/scssphp-scssphp)[fivefilters/readability.php

A PHP port of Readability.js

311826.8k5](/packages/fivefilters-readabilityphp)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[bezhansalleh/filament-panel-switch

Easily Switch between your Filament Panels

159323.5k2](/packages/bezhansalleh-filament-panel-switch)[jane-php/json-schema-runtime

Jane runtime Library

1811.1M13](/packages/jane-php-json-schema-runtime)

PHPackages © 2026

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