A PHP library for computing relative paths.

Clone this repo:
  1. b26ba5c build: Updating mediawiki/mediawiki-codesniffer to 50.0.0 by libraryupgrader · 8 days ago master
  2. 47e374e build: Updating composer dependencies by libraryupgrader · 2 weeks ago
  3. df70bb4 build: Upgrade mediawiki-phan-config for PHP 8.5 support by James D. Forrester · 3 weeks ago
  4. f9c6c97 build: Upgrade PHPUnit from 10.5.58 to 10.5.62 to unblock CI by James D. Forrester · 6 weeks ago
  5. 6d85e5f build: Upgrade mediawiki/mediawiki-phan-config from 0.17.0 to 0.18.0 by James D. Forrester · 6 weeks ago

RelPath

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