piyo2/path

Filesystem path utility

Maintainers

Details

github.com/piyo2/path

Source

Issues

Installs: 28

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/piyo2/path

v1.1.0 2023-10-18 08:33 UTC

This package is auto-updated.

Last update: 2025-09-18 12:48:48 UTC


README

Path utilities for PHP.

Installation

composer require piyo2/path

Usage

Join paths

use piyo2\util\path\Path;

Path::join('foo', 'bar'); // => 'foo/bar'
Path::join('foo', 'bar', 'baz'); // => 'foo/bar/baz'
Path::join('/foo', 'bar'); // => '/foo/bar'
Path::join('./foo', 'bar'); // => './foo/bar'
Path::join('/foo/bar/baz', '../qux'); // => '/foo/bar/qux'

Sanitize file name

use piyo2\util\path\Path;

Path::sanitizeFileName('foo'); // => 'foo'
Path::sanitizeFileName('f/o\\o<b>a|r'); // => 'f_o_o_b_a_r'
Path::sanitizeFileName('.foo'); // => 'foo'
Path::sanitizeFileName('foo..bar'); // => 'foo__bar'

// Allow beginning dot
Path::sanitizeFileName('.foo', true); // => '.foo'