[Filesystem] Add the Path class #41954
Open
+1,902
−1
Conversation
67755b1
to
aaa6d2a
* ".." segments at the beginning of relative paths are not removed. | ||
* | ||
* ```php | ||
* echo Path::canonicalize("\webmozart\puli\..\css\style.css"); |
OskarStark
Jul 3, 2021
Contributor
While I would agree keeping this as credits, should we change "webmozart" to "symfony" in examples?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Re-opening #30969 as requested by @fabpot.
This PR proposes a low-level, performant and pure API to manipulate file paths.
Two methods
Path::isAbsolute()
andPath::isRelative()
are similar toFilesystem::isAbsolutePath()
andFilesystem::makePathRelative()
. They are however different as the methods fromPath
do not check the existence of the path which is very helpful in some scenarios (for example when manipulating virtual paths such as "regular" paths of a PHAR).The original code comes from webmozart/path-util from which the path part was extracted. The library is very stable, well tested and documented. It has been heavily used in Puli, which although is no longer active has been a good performance test and is used in several other popular projects such as:
It however suffers from lack of maintener from @webmozart which no longer has time to maintain it.