proteins/url
Composer 安装命令:
composer require proteins/url
包简介
Helper object for parsing, building and handling URLs
README 文档
README
Protein | URL
Helper object for parsing, building and handling URLs
Install
composer require proteins/url
Require the class via :
use Proteins\URL;
Parse an URL
Create a new URL object passing the existing URL as constructor parameter, that will be automatically parsed into URL components.
$url = new URL('https://user:pass@www.alpha.beta.com:9080/path/to/resource.html?foo=bar&another[]=2&another[]=3#frag_link'); print_r($url);
Object
(
[scheme] => https
[user] => user
[pass] => pass
[host] => www.alpha.beta.com
[port] => 9080
[path] => /path/to/resource.html
[query] => Array
(
[foo] => bar
[another] => Array
(
[0] => 2
[1] => 3
)
)
[fragment] => frag_link
)
URL class can autocast itself as the builded URL string :
echo "$url";
https://user:pass@www.alpha.beta.com:9080/path/to/resource.html?foo=bar&another%5B0%5D=2&another%5B1%5D=3#frag_link
Build or modify an URL
You can modify or build from scratch an URL altering the single components :
$url = new URL(); $url->host = 'caffeina.com'; $url->user = 'demo'; echo $url;
demo@caffeina.com
$url = new URL("ftps://test.com:9000/index.php"); $url->scheme = 'https'; $url->port = false; echo $url;
https://test.com/index.php
Examples
Build a mailto address :
$link = new URL('mailto://'); $link->user = 'info'; $link->host = 'myserver.com'; $link->query['subject'] = 'This is a subject'; $link->query['body'] = 'Hi! This is a test... :D'; echo $link;
mailto://info@myserver.com?subject=This+is+a+subject&body=Hi%21+This+is+a+test...+%3AD
proteins/url 适用场景与选型建议
proteins/url 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 proteins/url 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 proteins/url 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-28
