kadokweb / path-converter
相对路径转换器
1.0.0
2022-01-14 12:09 UTC
Requires
- php: >=5.3.0
- ext-pcre: *
Requires (Dev)
- phpunit/phpunit: >=4.8
This package is auto-updated.
Last update: 2024-09-14 18:04:26 UTC
README
用法
use KadokWeb\PathConverter\Converter; $from = '/css/imports/icons.css'; $to = '/css/minified.css'; $converter = new Converter($from, $to); $result = $converter->convert('../../images/icon.jpg'); // $result is now '../images/icon.jpg'
方法
__construct($from, $to)
对象构造函数接受两个路径:文件当前相对于的源路径,以及要转换到的目标路径。
convert($path): string
$path 是相对文件,当前相对于 $from(在构造函数中)。返回值将是此文件的相对路径,但现在相对于 $to(在构造函数中)。
安装
如果您使用 Composer 来管理项目的依赖项,只需将 kadokweb/path-converter 作为依赖项添加到您的 composer.json 文件中即可。
composer require kadokweb/path-converter
"kadokweb/path-converter": "1.0.*"
尽管建议使用 Composer,但您实际上可以按任何方式包含这些文件。
许可协议
PathConverter 是 MIT 许可协议。