Bolt\Configuration\ResourceManager::findRelativePath PHP Method

findRelativePath() public method

Find the relative file system path between two file system paths.
public findRelativePath ( string $frompath, string $topath ) : string
$frompath string Path to start from
$topath string Path we want to end up in
return string Path leading from $frompath to $topath
    public function findRelativePath($frompath, $topath)
    {
        $filesystem = new Filesystem();
        $relative = $filesystem->makePathRelative($topath, $frompath);
        return $relative;
    }

Usage Example

示例#1
0
 public function testFindRelativePath()
 {
     $config = new ResourceManager(new \Pimple(['rootpath' => TEST_ROOT, 'pathmanager' => new PlatformFileSystemPathFactory()]));
     $rel = $config->findRelativePath(TEST_ROOT, TEST_ROOT . '/A/B');
     $this->assertEquals('A/B/', $rel);
 }