stevejoe / pathhelper
Node.js path.join-style path helper for PHP. Join and normalize path segments with the correct directory separator.
v1.0.0
2026-03-16 01:24 UTC
Requires
- php: >=8.0
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