stevejoe/pathhelper

Node.js path.join-style path helper for PHP. Join and normalize path segments with the correct directory separator.

Maintainers

Package info

github.com/stevejoe2026/pathhelper

pkg:composer/stevejoe/pathhelper

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-16 01:24 UTC

This package is auto-updated.

Last update: 2026-05-15 10:18:20 UTC


README

Node.js path.join-style path helper for PHP. Join and normalize path segments using the platform directory separator.

Installation

composer require stevejoe/pathhelper

Usage

use Stevejoe\Pathhelper\PathHelper;

// Join segments (like Node's path.join)
PathHelper::join('foo', 'bar', 'baz');        // "foo/bar/baz" (or "foo\bar\baz" on Windows)
PathHelper::join('foo/', '/bar');             // "foo/bar"
PathHelper::join('/var', 'www', 'app');       // "/var/www/app" on Unix

// Normalize a path (resolve . and ..)
PathHelper::normalize('foo/bar/../baz');      // "foo/baz"
PathHelper::normalize('/foo/./bar/');         // "/foo/bar"

// Directory and base name
PathHelper::dirname('/foo/bar/baz.txt');      // "/foo/bar"
PathHelper::basename('/foo/bar/baz.txt');     // "baz.txt"
PathHelper::basename('/foo/bar/baz.txt', '.txt'); // "baz"

Requirements

  • PHP 8.0+

License

MIT