承接 timostamm/url-builder 相关项目开发

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

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

timostamm/url-builder

Composer 安装命令:

composer require timostamm/url-builder

包简介

An URL object to parse, manipulate or create URLs with a fluent interface

README 文档

README

Build Status

An URL object to parse, manipulate or create URLs with a fluent interface.

Takes care of proper decoding / encoding of the path, query parameters and credentials.

The object exposes all components of common Web URLs as public properties:

$url = new Url('https://peter%40example.com:pass@domain.tld:8080/all+products/search?query=all#fragment');
$url->scheme->get(); // -> "https"
$url->host->get(); // -> "domain.tld"
$url->port->get(); // -> 8080
$url->credentials->username; // peter@example.com
$url->credentials->password;
$url->path->get(); // "all products/search"
$url->path->filename(); // "search"
$url->query->get('query'); // "all"
$url->fragment->get(); // "fragment"
$url->getUrl(); 

URL manipulation:

$url->clearHost(); // remove the scheme, host, port, credentials
$url->clearPath(); // remove the path, query, fragment
$url->clear(Url::QUERY | Url::FRAGMENT); // remove only specific components

// replace components with components from another URL
$url->replace('http://example.com/index.html', Url::SCHEME);
$url->replacePath('http://example.com/index.html');

$url = new Url('../styles/main.css');
$url->makeAbsolutePath('http://domain.tld/products/search'); // -> /styles/main.css
$url->makeAbsolute('http://domain.tld/products/search'); // -> http://domain.tld/styles/main.css

Path manipulation:

$url->path->set('automatically encöded/')
$url->path->normalize(); // resolves /foo/../bar to /bar
$url->filename(); // returns just the filename

Query manipulation:

$url->query->set('text', 'encöded');
$url->query->has('text');
$url->query->replace([
	'a' => 'foo', 
	'b' => 'bar'
]);
foreach( $url->query as list($key, $values) ) {
	print $key . ": " . join(', ', $values) . "\n"; 
}

Credentials manipulation:

$url->credentials->username = 'peter@example.com';
$url->credentials->password = 'pass;
$url->credentials->clear(); // removes username and password if present
$url->crdentials->isEmpty(); // Checks whether a username and/or password is present.
$url->crdentials->equals($otherUrl->credentials); // True if both are empty or both are same.

Comparing URLs or individual components:

$url->equals($otherUrl);
$url->equals('/all+products/search', Url::PATH);
$url->scheme->equals($otherUrl->scheme);

Common methods of all components:

->isEmpty(); // is the component present?
->clear(); // makes the component empty
->equals($otherurl->component); 

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固