Skip to content

utilities for handling and transforming file paths

Notifications You must be signed in to change notification settings

th3architect/php-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Path

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

About

utilities for handling and transforming file paths

Resources

Stars

Watchers

Forks

Packages

No packages published