wikimedia / relpath
Compute a relative filepath between two paths.
2.1.1
2018-01-18 21:23 UTC
Requires
- php: >=5.5.9
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.0.0
- mediawiki/mediawiki-codesniffer: 15.0.0
- phpunit/phpunit: ^4.8.9.0
README
RelPath is a small PHP library for computing a relative filepath to some path, either 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