Download the PHP package tasoft/tools-path without Composer
On this page you can find all versions of the php package tasoft/tools-path. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tasoft/tools-path
More information about tasoft/tools-path
Files in tasoft/tools-path
Package tools-path
Short Description Simple library to manipulate virtual paths
License MIT
Informations about the package tools-path
PHP Path Tools
This PHP library is a small tool to manage virtual paths.
Virtual paths are paths that don't have to exist on file system.
That leads to the problem of recognize if a path is a directory or a file.
To solve this problem, the library declares virtual paths using the following notations:
- Path with leading
/
is a zero path or absolute path. - Path with tailing
/
is a directory - component
..
is parent directory - component
.
is current directory -
empty components are ignored (ex:
/path///to/file.txt
=>/path/to/file.txt
)So the Path Tool provides two methods to determine if a path is a zero path or a directory
The core of PathTool
is the method yieldPathComponents
. It feeds other methods with path components. You can also use it directly with options described here:
- OPTION_RESOLVE: Resolves empty directories, parent and current directories.
- OPTION_DENY_OUT_OF_BOUNDS: Does not allow to choose parent directory of root directory (ex:
/root/path/../../../
) - OPTION_YIELD_ROOT: If a zero path, yields
/
as first component. - OPTION_YIELD_COMPONENT: Yields PathComponent object instead of strings.
- OPTION_ALL: Include all options described before.
Usage
Real Path Tool
The allows to perform simple task on real files and directories such as iterating over contents.
``