fyre/path

A path utility library.

v2.0.6 2024-06-25 04:11 UTC

This package is auto-updated.

Last update: 2024-06-25 04:11:41 UTC


README

FyrePath

FyrePath is a free, open-source path library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/path

In PHP:

use Fyre\Utility\Path;

Methods

Base Name

Get the base name from a file path.

  • $path is the file path.
$baseName = Path::baseName($path);

Dir Name

Get the directory name from a file path.

  • $path is the file path.
$dirName = Path::dirName($path);

Extension

Get the file extension from a file path.

  • $path is the file path.
$extension = Path::extension($path);

File Name

Get the file name from a file path.

  • $path is the file path.
$fileName = Path::fileName($path);

Format

Format path info as a file path.

  • $pathInfo is an array containing the path info.
$path = Path::format($pathInfo);

Is Absolute

Determine if a file path is absolute.

  • $path is the file path.
$isAbsolute = Path::isAbsolute($path);

Join

Join path segments.

All arguments supplied will be joined.

$path = Path::join(...$paths);

Normalize

Normalize a file path.

  • $path is the file path.
$normalized = Path::normalize($path);

Parse

Parse a file path.

  • $path is the file path.
$pathInfo = Path::parse($path);

Resolve

Resolve a file path from path segments.

All arguments supplied will be resolved.

$path = Path::resolve(...$paths);