承接 mtchabok/url 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mtchabok/url

Composer 安装命令:

composer require mtchabok/url

包简介

PHP Url Class

README 文档

README

PHP class for handling URLs.

  • Parse Url string Customized and create objects
  • check relative url
  • add or modify any part of the url objects
  • add or modify query parameters
  • compare any part of url with another url or part of that
  • support PSR-7 method`s

Installation

This package is listed on Packagist.

composer require mtchabok/url

How To Usage

Create Url Object

use \Mtchabok\Url\Url;

$url = new Url('https://www.domain.com/dir1/dir2/file.ext?param1=val1&param2=val2');

$url = Url::newUrl('https://www.domain.com/dir1/dir2/file.ext?param1=val1&param2=val2');

$url = Url::newUrl()
	->setScheme('https')
	->setAuthority('www.domain.com')
	->setPath('/dir1/dir2/file.ext')
	->setQuery('param1=val1&param2=val2')
;

Modify Url Object

use \Mtchabok\Url\Url;
$url = Url::newUrl();
// change scheme
$url->setScheme('http'); // return $url object
$url->scheme = 'http';

// change authority = user: sam, pass: 123, host: domain.com
$url->setAuthority('sam:123@domain.com'); // return $url object

// change url path.
$url->setPath('/dir2/dir1/'); // return $url object
$url->path = '/dir2/dir1/';

// add path
$url->addPath('./dir3/file.ext2'); // return $url object
$url->path = $url::normalizePath($url->path, './dir3/file.ext2');

// change query
$url->setQuery('p12=32&name=sara'); // return $url object
$url->query = 'p12=32&name=sara';

// set query param
$url->getQuery()->set('param1', 'test'); // return Url Query object
$url->query->set('param1', 'test'); // return Url Query object
$url->getQuery()->set('param4', ['p4_1'=>'val41', 'p4_2'=>'val42']); // return Url Query object
$url->query['param4'] = ['p4_1'=>'val41', 'p4_2'=>'val42']; // return Url Query object

// change fragment
$url->setFragment('index12'); // return $url object
$url->fragment = 'index12';

Check exist or set Url Properties

use \Mtchabok\Url\Url;
$url = Url::newUrl();
// check scheme set
$url->hasScheme(); // return bool

// check userInfo set
$url->hasUserInfo(); // return bool
$url->hasUser(); // return bool
$url->hasPass(); // return bool

// check host set
$url->hasHost(); // return bool

// check port set
$url->hasPort(); // return bool

// check path set
$url->hasPath(); // return bool

// check query set
$url->hasQuery(); // return bool

// and ...

Get Url Properties

use \Mtchabok\Url\Url;
$url = Url::newUrl();
// scheme
$url->getScheme(); // return current scheme or empty string
$url->scheme; // return current scheme or null
$url->getScheme('file'); // reutrn current scheme or 'file'

// user info
$url->getUserInfo(); // return current userinfo or empty string
$url->getUserInfo('test:123'); // return current userinfo or 'test:123'

// host
$url->getHost();  // return current host or empty string
$url->getHost('host.org');  // return current host or 'host.org'

// path
$url->getPath();  // return current path or empty string
$url->getPath('/dir1/dir2/file');  // return current path or '/dir1/dir2/file'

PSR-7 and Equals Method`s

use \Mtchabok\Url\Url;
$url = Url::newUrl('https://www.domain.com/dir1/dir2/file.ext');

$url2 = $url->withHost('site.com'); // return new Url Object with host 'site.com'

$url->equalsHost($url2->getHost()); // return false
$url->equalsHost($url2); // return false

For More Usage Documentation, Use This Url Class By IDE

mtchabok/url 适用场景与选型建议

mtchabok/url 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 05 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「url」 「php url」 「Url Class」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mtchabok/url 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mtchabok/url 我们能提供哪些服务?
定制开发 / 二次开发

基于 mtchabok/url 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-13