wikimedia / relpath
Work with file paths to join or find the relative path
4.0.0
2023-05-17 15:24 UTC
Requires
- php: >=7.4.3
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 41.0.0
- mediawiki/mediawiki-phan-config: 0.12.1
- mediawiki/minus-x: 1.1.1
- ockcyp/covers-validator: 1.6.0
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.3.2
- phpunit/phpunit: 9.5.28
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