PHP code example of ismaxim / path2

1. Go to this page and download the library: Download ismaxim/path2 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/ */

    

ismaxim / path2 example snippets




use Path2\Path;

/ For example, normalize some kinky path
$normalized = $path->to('/\/src/\\\Path2/\/\/\Path.php');

dd($normalized); // "{CWD}/src/Path2/Path.php" (on an UNIX) || "{CWD}\src\Path2\Path.php" (on a Windows)
                 
                 // Note, by default if any preceding to the main path (first argument),
                 // from-path (second argument) isn't passed then Path::to()
                 // uses CWD (current working directory) as a preceding, from-path.