2017 © Pedro Peláez
 

library path

PHP 5.4 port of the node/iojs path module

image

weevers/path

PHP 5.4 port of the node/iojs path module

  • Thursday, April 2, 2015
  • by weevers
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7,526 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

path

PHP 5.4 port of the node/iojs path module, because PHP is like a family holiday dinner and I want to survive. Description from the iojs documentation:, (*1)

This module contains utilities for handling and transforming file paths. Almost all these methods perform only string transformations. The file system is not consulted to check whether paths are valid., (*2)

packagist status Travis build status AppVeyor build status Dependency status, (*3)

Jump to: usage / install / license, (*4)

examples

Example output on a posix system, assuming "/please" is the current working directory:, (*5)


usage

Usage docs pending. In the meantime, consult the iojs documentation, because the function signatures are almost the same and the code (including unit tests) copied., (*6)

Ported so far (for posix and windows), including unit tests

  • relative($from, $to)
  • isAbsolute($path)
  • resolve($path, ..)
  • join($path, ..)
  • normalize($path)
  • separator()
  • delimiter()

PHP-specific additions

resolve() also accepts stream wrapper URI's. This is implemented outside of the (ported) posix and Windows adapters, to ensure it doesn't interfere with the original behavior (which remains well tested and has a frozen stability)., (*7)

  • file schemes are stripped, unless combined with other schemes
  • A scheme change is interpreted like a root change. E.g. going from http://x to glob://x acts like a cd from c:\x to d:\x.
  • For remote streams (like http) and vfs streams, the arguments passed to resolve() are joined (instead of resolved to an absolute path) with forward slashes (regardless of OS).

Some examples (for Windows, so you can see the difference between local and remote streams), assuming "C:\project" is the current working directory:, (*8)


Additional methods

  • isInside($path, $parent) - similar to sindresorhus/is-path-inside for node
  • getPrefix($path) - returns "zip://" for "zip://2015.zip#april/02.log"

install

With composer do:, (*9)

composer require weevers/path

license

MIT © Vincent Weevers and iojs/node authors., (*10)

The Versions

02/04 2015

dev-master

9999999-dev https://github.com/vweevers/php-path

PHP 5.4 port of the node/iojs path module

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

utils nodejs path node resolve relative iojs

02/04 2015

v0.2.0

0.2.0.0 https://github.com/vweevers/php-path

PHP 5.4 port of the node/iojs path module

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

utils nodejs path node resolve relative iojs

31/03 2015

v0.1.0

0.1.0.0 https://github.com/vweevers/php-path

PHP 5.4 port of the node/iojs path module

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

utils nodejs path node resolve relative iojs

31/03 2015

v0.0.1

0.0.1.0 https://github.com/vweevers/php-path

PHP 5.4 port of the node/iojs path module

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

utils nodejs path node resolve relative iojs