| 1 |
# Path converter |
| 2 |
|
| 3 |
[](https://travis-ci.org/matthiasmullie/path-converter](https://travis-ci.org/matthiasmullie/path-converter](https://travis-ci.org/matthiasmullie/path-converter) |
| 4 |
[](https://codecov.io/github/matthiasmullie/path-converter](https://codecov.io/github/matthiasmullie/path-converter](https://codecov.io/github/matthiasmullie/path-converter) |
| 5 |
[](https://scrutinizer-ci.com/g/matthiasmullie/path-converter](https://scrutinizer-ci.com/g/matthiasmullie/path-converter](https://scrutinizer-ci.com/g/matthiasmullie/path-converter) |
| 6 |
[](https://packagist.org/packages/matthiasmullie/path-converter](https://packagist.org/packages/matthiasmullie/path-converter](https://packagist.org/packages/matthiasmullie/path-converter) |
| 7 |
[](https://packagist.org/packages/matthiasmullie/path-converter](https://packagist.org/packages/matthiasmullie/path-converter](https://packagist.org/packages/matthiasmullie/path-converter) |
| 8 |
[](https://github.com/matthiasmullie/path-converter/blob/master/LICENSE](https://github.com/matthiasmullie/path-converter/blob/master/LICENSE](https://github.com/matthiasmullie/path-converter/blob/master/LICENSE) |
| 9 |
|
| 10 |
|
| 11 |
## Usage |
| 12 |
|
| 13 |
```php |
| 14 |
use MatthiasMullie\PathConverter\Converter; |
| 15 |
|
| 16 |
$from = '/css/imports/icons.css'; |
| 17 |
$to = '/css/minified.css'; |
| 18 |
|
| 19 |
$converter = new Converter($from, $to); |
| 20 |
$result = $converter->convert('../../images/icon.jpg'); |
| 21 |
// $result is now '../images/icon.jpg' |
| 22 |
``` |
| 23 |
|
| 24 |
|
| 25 |
## Methods |
| 26 |
|
| 27 |
### __construct($from, $to) |
| 28 |
|
| 29 |
The object constructor accepts 2 paths: the source path your file(s) is/are |
| 30 |
currently relative to, and the target path to convert to. |
| 31 |
|
| 32 |
### convert($path): string |
| 33 |
|
| 34 |
$path is the relative file, which is currently relative to $from (in |
| 35 |
constructor). The return value will be the relative path of this same file, but |
| 36 |
now relative to $to (in constructor) |
| 37 |
|
| 38 |
|
| 39 |
## Installation |
| 40 |
|
| 41 |
Simply add a dependency on matthiasmullie/path-converter to your composer.json file if you use [Composer](https://getcomposer.org/) to manage the dependencies of your project: |
| 42 |
|
| 43 |
```sh |
| 44 |
composer require matthiasmullie/path-converter |
| 45 |
``` |
| 46 |
|
| 47 |
Although it's recommended to use Composer, you can actually include these files anyway you want. |
| 48 |
|
| 49 |
|
| 50 |
## License |
| 51 |
|
| 52 |
PathConverter is [](http://opensource.org/licenses/MITMIT](http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT) licensed. |
| 53 |
|