2017 © Pedro Peláez
 

library path-helper

Helper class for creating relative paths, absolutizing, etc.

image

czproject/path-helper

Helper class for creating relative paths, absolutizing, etc.

  • Sunday, June 24, 2018
  • by janpecha
  • Repository
  • 1 Watchers
  • 2 Stars
  • 312 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 9 % Grown

The README.md

CzProject\PathHelper

Build Status Downloads this Month Latest Stable Version License, (*1)

Helper class for creating relative paths, absolutizing paths,..., (*2)

Donate, (*3)

Installation

Download a latest package or use Composer:, (*4)

composer require czproject/path-helper

Library requires PHP 5.6.0 or later., (*5)

Usage

``` php use CzProject\PathHelper;, (*6)


### Absolutize path ``` php PathHelper::absolutizePath($path); PathHelper::absolutizePath('path/to/my/../text/./file.txt');

Returns /path/to/text/file.txt, (*7)

You can use second parameter $prefix:, (*8)

``` php PathHelper::absolutizePath('path/to/my/../text/./file.txt', NULL); // returns path/to/text/file.txt PathHelper::absolutizePath('path/to/my/../text/./file.txt', '/file/root/'); // returns /file/root/path/to/text/file.txt, (*9)



### Creating relative path ``` php $source = 'root/dir/docs/1.0/index.html'; $dest = 'root/dir/imgs/image.jpg'; PathHelper::createRelativePath($source, $dest);

Returns ../../imgs/image.jpg, (*10)

Is path current?

``` php PathHelper::isPathCurrent($path, $mask);, (*11)

PathHelper::isPathCurrent('dir/file.txt', 'dir/file-2.txt'); // returns FALSE PathHelper::isPathCurrent('dir/file.txt', 'dir/'); // returns TRUE PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/'); // returns FALSE PathHelper::isPathCurrent('dir/sub/file.txt', 'dir//'); // returns TRUE PathHelper::isPathCurrent('dir/sub/file.txt', 'dir/**'); // returns TRUE, (*12)


| Mask | Meaning | -------- | ------------------------------------------ | ```**``` | means *everything* | ```*``` | means *everything <b>except</b> ```/```* ### Normalize path Normalizes path delimiters to `/`. ``` php PathHelper::normalizePath($path); PathHelper::normalizePath('\\path\\to\\file.txt');

Returns /path/to/file.txt., (*13)

Helper instance

php $helper = new CzProject\PathHelper; $helper->absolutizePath('/path/to/to/../file'); $helper->createRelativePath('/path/to/file', '/path/to'); $helper->isPathCurrent('/path/file', '/path/*');, (*14)


License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/, (*15)

The Versions

24/06 2018

dev-master

9999999-dev

Helper class for creating relative paths, absolutizing, etc.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

24/06 2018

v4.1.0

4.1.0.0

Helper class for creating relative paths, absolutizing, etc.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

23/12 2015

v4.0.0

4.0.0.0

Helper class for creating relative paths, absolutizing, etc.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

04/09 2015

v3.0.0

3.0.0.0

Helper class for creating relative paths, absolutizing, etc.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

27/07 2015

v2.0.0

2.0.0.0

Helper class for generating relative paths, absolutizing paths,…

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

23/03 2014

v1.0.0

1.0.0.0

Helper class for generating relative paths, absolutizing paths,…

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

The Development Requires