Download the PHP package gzqsts/file-path without Composer
On this page you can find all versions of the php package gzqsts/file-path. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download gzqsts/file-path
More information about gzqsts/file-path
Files in gzqsts/file-path
Download gzqsts/file-path
More information about gzqsts/file-path
Files in gzqsts/file-path
Please rate this library. Is it a good library?
Informations about the package file-path
File Path - 文件路径处理工具包
提供强大的文件路径解析、操作和格式化功能。
功能特性
- ✅ 路径解析:支持解析文件路径、URL路径等
- ✅ 不可变对象:所有修改操作返回新实例,保证数据安全
- ✅ 链式调用:支持流畅的链式操作
- ✅ 路径操作:支持路径追加、修改、替换等操作
- ✅ 文件信息:获取文件名、扩展名、目录等
- ✅ 分隔符控制:支持自定义目录分隔符
- ✅ URL支持:支持解析和操作URL路径
环境要求
- PHP >= 8.0
安装
通过 Composer 安装:
快速开始
基本用法
创建路径对象
获取路径信息
修改路径
所有修改操作都返回新的 Path 实例,原对象不变(不可变对象模式)。
设置目录分隔符
路径字符串转换
创建目录
链式调用
完整示例
API 参考
构造函数
创建一个新的 Path 实例。
获取方法
getScheme(): string- 获取协议(如 http, https)getHost(): string- 获取主机名getPort(): string- 获取端口号getQuery(): string- 获取查询参数getFilename(): ?string- 获取文件名(不含扩展名)getExtension(): ?string- 获取文件扩展名getBasename(): ?string- 获取完整文件名(含扩展名)getPath(): string- 获取目录路径部分getFull(): string- 获取完整路径(包含协议、主机等)
修改方法(返回新实例)
withScheme(string $scheme): Path- 设置协议withHost(string $host): Path- 设置主机withPort(string $port): Path- 设置端口withQuery(string $query): Path- 添加查询参数withFilename(string $filename): Path- 设置文件名withExtension(string $extension): Path- 设置扩展名withBasename(string $basename): Path- 设置完整文件名withPath(string $directory): Path- 追加目录路径withPathAll(string $path): Path- 替换整个目录路径withDirSeparator(string $dirSeparator): Path- 设置目录分隔符
转换方法
__toString(): string- 转换为字符串toString(string $addPath = ''): string- 转换为字符串(可添加前缀路径)
静态方法
createDirs(string $filePath): void- 创建目录(如果不存在)composeComponents(array $pathInfo, string $dirSeparator): string- 组合路径组件
注意事项
- 不可变对象:所有
with*方法都返回新的Path实例,原对象不会被修改 - 路径规范化:构造函数会自动将反斜杠转换为正斜杠,并规范化路径
- 空值处理:获取方法可能返回空字符串或
null,请根据实际情况处理 - URL支持:支持解析和操作URL路径,包括协议、主机、端口和查询参数
All versions of file-path with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.0
The package gzqsts/file-path contains the following files
Loading the files please wait ...