wikimedia / relpath
Work with file paths to join or find the relative path
4.0.1
2024-11-11 07:47 UTC
Requires
- php: >=7.4.3
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 45.0.0
- mediawiki/mediawiki-phan-config: 0.14.0
- mediawiki/minus-x: 1.1.3
- ockcyp/covers-validator: 1.6.0
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpunit/phpunit: 9.6.16
README
RelPath is a small PHP library for working with file paths, to join two paths, or find the relative path to a path from the current directory or from an optional start directory.
Here is how you use it:
$relPath = \Wikimedia\RelPath::getRelativePath( '/srv/mediawiki/resources/src/startup.js', '/srv/mediawiki' ); // Result: "resources/src/startup.js" $fullPath = \Wikimedia\RelPath::joinPath( '/srv/mediawiki', 'resources/src/startup.js' ); // Result: "/srv/mediawiki/resources/src/startup.js" $fullPath = \Wikimedia\RelPath::joinPath( '/srv/mediawiki', '/var/startup/startup.js' ); // Result: "/var/startup/startup.js"
The RelPath::joinPath()
function provided here is analogous to os.path.join()
in Python,
and path.join()
found in Node.js.
License
MIT