PHPackages                             nelwhix/filepath - 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. nelwhix/filepath

ActiveLibrary

nelwhix/filepath
================

file i/o utilities for different OS architectures

v1.0.1(2y ago)04[1 issues](https://github.com/Nelwhix/filepath/issues)PHP

Since May 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Nelwhix/filepath)[ Packagist](https://packagist.org/packages/nelwhix/filepath)[ RSS](/packages/nelwhix-filepath/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Filepath
========

[](#filepath)

A simple class with some static methods for manipulating file paths properly regardless of system architecture

Motivation
----------

[](#motivation)

I was working on a legacy PHP project where there was all sort of code like this:

```
    $routes = include(__DIR_ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'routes.php');
```

I then remembered that golang's filepath package would fluently join a url like this. So this is a port of the methods in golang's path/filepath package

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

[](#installation)

```
    composer require nelwhix/filepath
```

Usage
-----

[](#usage)

- Join Method: Using the static 'join' method the code for the example earlier will look like this:

```
    $url = \Nelwhix\Filepath\Filepath::join(__DIR__, 'src', 'routes.php');
    $routes = include($url);
```

- Base method: The base method returns the last part of any filepath passed to it. Like this:

```
    \Nelwhix\Filepath\Filepath::base("/foo/bar/baz.js");
    // this will return "baz.js"
```

- Abs method: The abs method returns the absolute path to the filepath given:

```
    \Nelwhix\Filepath\Filepath::abs("Filepath.php");
    // this returns "\C:\Users\USER PC\Documents\Open Source contributions\filepath\src\Filepath.php"
```

- Dir method: The dir method returns the directory in a path:

```
    \Nelwhix\Filepath\Filepath::dir("/foo/bar/baz.js")
    // returns "/foo/bar"
```

- clean method: The clean method removes double and trailing slashes from a filepath e.g.

```
    \Nelwhix\Filepath\Filepath::clean("//dirty///path////");
    // this returns /dirty/path
```

- ext method: The ext method returns the extension of the file in the filepath. if a directory is passed it returns an empty string.

```
    \Nelwhix\Filepath\Filepath::ext("/src/routes.php");
    // returns ".php"
```

- split method: The split method returns an object that contains the directory and file from the filepath

```
    $split = \Nelwhix\Filepath\Filepath::split("./Documents/side-projects/filepath/composer.json");
    $split->dir; // ./Documents/side-projects/filepath
    $split->file; // composer.json
```

- walk method: The walk method takes a directory and a callback function to run on each file in the directory.

```
    Filepath::walk("C:\Users\USER PC\Documents\\300L books", function (\DirectoryIterator $param) {
        if($param->isDot()) return;
        echo $param->getFilename() . "\n";
    });
```

- glob method: The glob method returns all the files in a directory that match a pattern. To return all the files ending in ".php":

```
    Nelwhix\Filepath\Filepath::glob(".php", "side-projects/src");
    // returns an array containing the files matching the pattern
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

Total

2

Last Release

1087d ago

### Community

Maintainers

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

---

Top Contributors

[![Nelwhix](https://avatars.githubusercontent.com/u/58360242?v=4)](https://github.com/Nelwhix "Nelwhix (12 commits)")

---

Tags

filepathphp

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/nelwhix-filepath/health.svg)

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

PHPackages © 2026

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