PHPackages                             pathtype/pathtype - 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. pathtype/pathtype

ActiveLibrary

pathtype/pathtype
=================

Unix path manipulation

151PHP

Since Aug 30Pushed 12y agoCompare

[ Source](https://github.com/rubendg/pathtype)[ Packagist](https://packagist.org/packages/pathtype/pathtype)[ RSS](/packages/pathtype-pathtype/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

PathType - Unix path manipulation
=================================

[](#pathtype---unix-path-manipulation)

[![Build Status](https://camo.githubusercontent.com/3f89f0a57db526865d14bf3fc0db857338039fbe5d9cff093fe0ee46d7a053c4/68747470733a2f2f6170692e7472617669732d63692e6f72672f727562656e64672f70617468747970652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/rubendg/pathtype)

An OO library for Unix path manipulation. The properties of a path absolute/relative file or directory are reflected in the type and invalid operations (like appending an absolute directory path to an relative file path) are simply not possible by construction.

The library is heavily inspired by the Haskell [pathtype](http://hackage.haskell.org/package/pathtype) library, but is not meant to be a port in anyway. Here is the type hierachy:

[![Type hierarchy](https://github.com/rubendg/pathtype/raw/master/doc/types.png)](https://github.com/rubendg/pathtype/raw/master/doc/types.png)

A quick example.

Using the factory function `Path::from` we can produce any of the types in the bottom of the diagram. It takes a well-formed path string and a flag indicating whether the path is a directory or a file (since this cannot actually be determined from the path in all cases).

```
$path = '/etc/apache2/site-enabled';
$sitesEnabled = Path::from($path, is_dir($path));

function newApacheConfig(AbsDir $sitesEnabled, $name) {
   mkdir($sitesEnabled
   ->append('sites-enabled')
   ->append($name)
   ->get());
}

newApacheConfig($sitesEnabled);
```

One of the added benefits besides the path manipulation functions is that we can now use type hinting in order to express that *newApacheConfig* expects an absolute directory path.

Notes:

- The filesystem is never touched by the library.
- No tilde (~) support. Let the OS resolve the tilde to the actual home directory before using the library.

Warning: this library is not battle tested

Similar:

-
-

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![rubendg](https://avatars.githubusercontent.com/u/439057?v=4)](https://github.com/rubendg "rubendg (7 commits)")

### Embed Badge

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

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

PHPackages © 2026

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