Documentation

Converter
in package
implements ConverterInterface

Convert paths relative from 1 file to another.

E.g. ../../images/icon.jpg relative to /css/imports/icons.css becomes ../images/icon.jpg relative to /css/minified.css

Please report bugs on https://github.com/matthiasmullie/path-converter/issues

Tags
author

Matthias Mullie pathconverter@mullie.eu

copyright

Copyright (c) 2015, Matthias Mullie. All rights reserved

license

MIT License

Table of Contents

Interfaces

ConverterInterface
Convert file paths.

Properties

$from  : string
$to  : string

Methods

__construct()  : mixed
convert()  : string
Convert paths relative from 1 file to another.
dirname()  : string
Attempt to get the directory name from a path.
normalize()  : string
Normalize path.
shared()  : string
Figure out the shared path of 2 locations.

Properties

Methods

__construct()

public __construct(string $from, string $to[, string $root = '' ]) : mixed
Parameters
$from : string

The original base path (directory, not file!)

$to : string

The new base path (directory, not file!)

$root : string = ''

Root directory (defaults to getcwd)

convert()

Convert paths relative from 1 file to another.

public convert(string $path) : string

E.g. ../images/img.gif relative to /home/forkcms/frontend/core/layout/css should become: ../../core/layout/images/img.gif relative to /home/forkcms/frontend/cache/minified_css

Parameters
$path : string

The relative path that needs to be converted

Return values
string

The new relative path

dirname()

Attempt to get the directory name from a path.

protected dirname(string $path) : string
Parameters
$path : string
Return values
string

normalize()

Normalize path.

protected normalize(string $path) : string
Parameters
$path : string
Return values
string

shared()

Figure out the shared path of 2 locations.

protected shared(string $path1, string $path2) : string

Example: /home/forkcms/frontend/core/layout/images/img.gif and /home/forkcms/frontend/cache/minified_css share /home/forkcms/frontend

Parameters
$path1 : string
$path2 : string
Return values
string

        
On this page

Search results