donut/path

utilities for handling and transforming file paths

This package's canonical repository appears to be gone and the package has been frozen as a result.

0.1.0 2014-08-19 10:12 UTC

This package is not auto-updated.

Last update: 2021-01-04 08:07:08 UTC


README

Utilities for handling and transforming file paths.

The file system is not checked to verify whether paths are valid.

Installation

path lives on packagist.org

$ composer require donut/path

Usage

<?php require "vendor/autoload.php";

use \Donut\Path as p;

$path = p\join("/usr/local", "bin", "/donut");
// /usr/local/bin/donut

API

string canonicalize( string $path [, string $root = getcwd() ] )

<?php

chdir("/home/donut");

canonicalize("a/b/c.ext");
// => /home/donut/a/b/c.ext

canonicalize("a/b/c.ext", "/root");
// => /root/a/b/c.ext

canonicalize("/home/donut/club.ext", "/root");
// => /home/donut/club.ext

bool is_absolute( string $path )

<?php is_absolute("/home/donut");
// => true

string normalize( string $path )

<?php normalize("/a/b/../c/./d.ext");
// => /a/c/d.ext

string join( string $part1 [, string $...] )

<?php join("/usr", "local", "/bin", "./donut");
// => /usr/local/bin/donut

Attribution

License

BSD 3-Clause