- Notifications
You must be signed in to change notification settings - Fork0
Normalize paths to files & directories in PHP
License
maximgrynykha/path2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
If you are not confident that your program will properly lead the way to the required file or directory - use Path2, it automatically converts all slashes to those which are used in the current operating system, yet so over also will trim excess slashes if there are in the path.
To install this library - run the command below in your terminal:
composer require maximgrynykha/path2
<?phpusePath2\Path;require_once'vendor/autoload.php';$path =newPath();// 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.
Param | Argument | Example |
---|---|---|
path | [string]: any path to the file or dir | |
from | [string]: any path preceding before the main path | CWD (current working directory) |
__DIR__, __NAMESPACE__, etc. |
If you have a problem that cannot be solved using this library, please write your solution, and if you want to helpother developers who also use this library (or if you want to keep your solution working after a new version isreleased, which will be in the package manager dependencies) — create a pull-request. I will be happy to add yourexcellent code to the library!
🐞 Report any bugs or issues you find on theGitHub issues.
The MIT License (MIT). Please seeLicense File for more information.
About
Normalize paths to files & directories in PHP