PHP code example of ama-team / pathetic
1. Go to this page and download the library: Download ama-team/pathetic library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ama-team / pathetic example snippets
use AmaTeam\Pathetic\Path;
$path = Path::parse('beverages/soda');
$path = Path::parse('file://beverages/soda');
$path = Path::parse('c:\\beverages\\soda', Path::PLATFORM_WINDOWS);
$path = Path::parse('c:/beverages/soda', Path::PLATFORM_WINDOWS);
$path = Path::parse('custom-scheme://c:/beverages/soda', Path::PLATFORM_WINDOWS);
$path = Path::parse('file://beverages\\soda');
echo (string) $path; // file://beverages/soda
echo $path->toPlatformString(); // file://beverages\\soda
$path = Path::parse('/node/directory//./../leaf');
echo (string) $path; # /node/directory//./../leaf
echo $path->normalize(); # /node/leaf
$path->isAbsolute(); # true
$node = Path::parse('/node');
$leaf = Path::parse('leaf');
$other = $node->resolve($leaf); # /node/leaf
$path->isChildOf($node); # true
$path->isSiblingOf($other); # true
$path->equals($other); # true
echo (string) $path->getParent(); # /node
echo (string) $node->relativize($path); # leaf
foreach ($path->iterator() as $entry) {
echo (string) $entry;
# /
# /node
# /node/leaf
}
$path = Path::parse('file://c:/node/directory', Path::PLATFORM_WINDOWS);
$path = $path->withoutScheme()->withRoot('d:');
echo $path->getRoot(); # d:
echo $path->getScheme(); # null
echo $path->getSeparator(); # \ - because of windows platform