1. Go to this page and download the library: Download neunerlei/path-util 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/ */
neunerlei / path-util example snippets
>= 7.3.0
use Neunerlei\PathUtil\Path;
// These methods are added by this fork
// ==========================================================
echo Path::unifySlashes("\\foo/bar\\baz");
// => /foo/bar/baz (on linux) or \foo\bar\baz (on windows)
echo Path::unifyPath("\\foo/bar\\baz");
// => /foo/bar/baz/ (on linux) or \foo\bar\baz\ (on windows)
echo Path::classBasename(\Neunerlei\PathUtil\Path::class);
// => Path
echo Path::classNamespace(\Neunerlei\PathUtil\Path::class);
// => Neunerlei\PathUtil
$link = Path::makeUri();
// => Returns a new Uri object -> See "URI" Section for details.
// Those methods were already in the base implementation
// ==========================================================
echo Path::canonicalize('/var/www/vhost/webmozart/../config.ini');
// => /var/www/vhost/config.ini
echo Path::canonicalize('C:\Programs\Webmozart\..\config.ini');
// => C:/Programs/config.ini
echo Path::canonicalize('~/config.ini');
// => /home/webmozart/config.ini
echo Path::makeAbsolute('config/config.yml', '/var/www/project');
// => /var/www/project/config/config.yml
echo Path::makeRelative('/var/www/project/config/config.yml', '/var/www/project/uploads');
// => ../config/config.yml
$paths = array(
'/var/www/vhosts/project/httpdocs/config/config.yml',
'/var/www/vhosts/project/httpdocs/images/banana.gif',
'/var/www/vhosts/project/httpdocs/uploads/../images/nicer-banana.gif',
);
Path::getLongestCommonBasePath($paths);
// => /var/www/vhosts/project/httpdocs
Path::getFilename('/views/index.html.twig');
// => index.html.twig
Path::getFilenameWithoutExtension('/views/index.html.twig');
// => index.html
Path::getFilenameWithoutExtension('/views/index.html.twig', 'html.twig');
Path::getFilenameWithoutExtension('/views/index.html.twig', '.html.twig');
// => index
Path::getExtension('/views/index.html.twig');
// => twig
Path::hasExtension('/views/index.html.twig');
// => true
Path::hasExtension('/views/index.html.twig', 'twig');
// => true
Path::hasExtension('/images/profile.jpg', array('jpg', 'png', 'gif'));
// => true
Path::changeExtension('/images/profile.jpeg', 'jpg');
// => /images/profile.jpg
Path::join('phar://C:/Documents', 'projects/my-project.phar', 'composer.json');
// => phar://C:/Documents/projects/my-project.phar/composer.json
Path::getHomeDirectory();
// => /home/webmozart
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.