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

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

matthiasmullie/path-converter
=============================

Relative path converter

1.1.3(7y ago)10229.6M—6.5%14[2 issues](https://github.com/matthiasmullie/path-converter/issues)[1 PRs](https://github.com/matthiasmullie/path-converter/pulls)7MITPHPPHP &gt;=5.3.0

Since Feb 20Pushed 2y ago8 watchersCompare

[ Source](https://github.com/matthiasmullie/path-converter)[ Packagist](https://packagist.org/packages/matthiasmullie/path-converter)[ Docs](http://github.com/matthiasmullie/path-converter)[ RSS](/packages/matthiasmullie-path-converter/feed)WikiDiscussions master Synced 1mo ago

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

Path converter
==============

[](#path-converter)

[![Build status](https://camo.githubusercontent.com/297c768851a03d7e6a8962d90ddc406c301d4b582419dc029ce5057196907532/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617474686961736d756c6c69652f706174682d636f6e7665727465722f746573742e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/matthiasmullie/path-converter/actions/workflows/test.yml)[![Code coverage](https://camo.githubusercontent.com/6cfa328a086271574693a2ceda76428628c2118c4dbce768f634e155170a77a0/687474703a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f6d617474686961736d756c6c69652f706174682d636f6e7665727465723f7374796c653d666c61742d737175617265)](https://codecov.io/gh/matthiasmullie/path-converter)[![Latest version](https://camo.githubusercontent.com/f28b3d5079c5b7f8fcfda2bdb2501af47b249a18f8267f31bf3efa2aee704583/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617474686961736d756c6c69652f706174682d636f6e7665727465723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/matthiasmullie/path-converter)[![Downloads total](https://camo.githubusercontent.com/3f9889e374c8e4b10ec97811a103a845b133bf929de36a67bce89723907a0ce1/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617474686961736d756c6c69652f706174682d636f6e7665727465723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/matthiasmullie/path-converter)[![License](https://camo.githubusercontent.com/8b521a367446276441f51948065180c61b346f0c2f68f9975125d28cb8076b43/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d617474686961736d756c6c69652f706174682d636f6e7665727465723f7374796c653d666c61742d737175617265)](https://github.com/matthiasmullie/path-converter/blob/master/LICENSE)

Usage
-----

[](#usage)

```
use MatthiasMullie\PathConverter\Converter;

$from = '/css/imports/icons.css';
$to = '/css/minified.css';

$converter = new Converter($from, $to);
$result = $converter->convert('../../images/icon.jpg');
// $result is now '../images/icon.jpg'
```

Methods
-------

[](#methods)

### \_\_construct($from, $to)

[](#__constructfrom-to)

The object constructor accepts 2 paths: the source path your file(s) is/are currently relative to, and the target path to convert to.

### convert($path): string

[](#convertpath-string)

$path is the relative file, which is currently relative to $from (in constructor). The return value will be the relative path of this same file, but now relative to $to (in constructor)

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

[](#installation)

Simply add a dependency on `matthiasmullie/path-converter` to your composer.json file if you use [Composer](https://getcomposer.org/) to manage the dependencies of your project:

```
composer require matthiasmullie/path-converter
```

Although it's recommended to use Composer, you can actually include these files anyway you want.

License
-------

[](#license)

PathConverter is [MIT](http://opensource.org/licenses/MIT) licensed.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity64

Solid adoption and visibility

Community23

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 84.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 ~120 days

Recently: every ~253 days

Total

13

Last Release

2659d ago

### Community

Maintainers

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

---

Top Contributors

[![matthiasmullie](https://avatars.githubusercontent.com/u/312776?v=4)](https://github.com/matthiasmullie "matthiasmullie (39 commits)")[![remyperona](https://avatars.githubusercontent.com/u/3465180?v=4)](https://github.com/remyperona "remyperona (7 commits)")

---

Tags

pathconverterrelativepaths

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/uri-components

URI components manipulation library

31932.3M67](/packages/league-uri-components)[mark-gerarts/auto-mapper-plus

An AutoMapper for PHP

5623.2M21](/packages/mark-gerarts-auto-mapper-plus)[iamcal/php-emoji

This is a PHP library for dealing with Emoji, allowing you to convert between various native formats and displaying them using HTML.

1.3k481.1k](/packages/iamcal-php-emoji)[ncjoes/office-converter

PHP Wrapper for LibreOffice

2431.2M4](/packages/ncjoes-office-converter)[henck/rtf-to-html

RTF to HTML converter in PHP

108785.6k1](/packages/henck-rtf-to-html)[sebastianfeldmann/camino

Path management the OO way

176.4M1](/packages/sebastianfeldmann-camino)

PHPackages © 2026

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