midnite81/urlparser
Composer 安装命令:
composer require midnite81/urlparser
包简介
A PHP 7.1+ package to parse urls
README 文档
README
A PHP 7.1+ URL parser for easy manipulation of URLs
Installation
This package requires PHP 7.1+.
To install through composer include the package in your composer.json.
"midnite81/urlparser": "^1.0"
Run composer install or composer update to download the dependencies or you can run
composer require midnite81/urlparser.
Example Usage
<?php include '/path/to/vendor/autoload.php'; $url = new Midnite81\UrlParser\Url('http://example.com/gallery/houses?hiRes=1#forSale'); echo $url->path(); // returns '/gallery/houses' echo $url->fileName() // returns 'houses'
Available Methods
| Method | Returns | Description |
|---|---|---|
| all() | array | Returns all parts of the URL as an array |
| json() | json | Returns all parts of the URL as a JSON object |
| get(string $key) | string or null | Returns the value of a URL part, if it exists |
| scheme() | string | Returns the scheme e.g. http |
| host() | string | Returns the host e.g example.com |
| port() | string | Returns the port e.g. 80 |
| user() | string | Returns the user |
| pass() | string | Returns the password |
| path() | string | Returns the path e.g. /gallery/houses |
| fileName() | string | Returns the filename e.g. example.pdf |
| query(bool $includeQuestionMark = false) | string | Returns the querystring e.g. hiRes=1 |
| fragment(bool $includeHash = false) | string | Returns the fragment e.g forSale |
| segments() | array | Returns each segment of the URL path |
| segment(int $index) | string or null | Returns the requested segment of the URL Path, if it exists |
| encode(int $times = 1) | string | Returns the url encoded (urlencode). |
| doubleEncode() | string | Returns the url double encoded |
| queryArray() | array | Returns the Query String back in an associative array |
| fragmentArray() | array | Returns the Fragments back in an associative array |
| getQueryValue(string $key) | string or null | Returns the value of the query string key if it exists |
| getHashValue(string $key) | string or null | Returns the value of the fragment/hash key if it exists |
midnite81/urlparser 适用场景与选型建议
midnite81/urlparser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.3k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 midnite81/urlparser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 midnite81/urlparser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-25