kusabi / uri
一个符合PSR-7和PSR-17的PHP uri库
1.0.4
2019-07-13 21:35 UTC
Requires
- php: ^7.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- codacy/coverage: ^1.4
- friendsofphp/php-cs-fixer: ^2.15
- phan/phan: ^1.2
- phpunit/phpunit: ^6.5
- symfony/var-dumper: ^3.4
README
安装
使用composer进行简单安装。
composer require kusabi/uri
或者直接将它添加到你的composer.json
文件中
{ "require": { "kusabi/uri": "^1.0" } }
使用Uri类
Uri类是一个简单的Uri字符串包装器。
use Kusabi\Uri\Uri; // Instantiate a Uri instance $uri = new Uri('https://user:pass@www.my-site.com:8080/users/22?filter=name#bottom'); // Fetch the properties of the Uri instance echo $uri->getScheme(); echo $uri->getAuthority(); echo $uri->getUserInfo(); echo $uri->getHost(); echo $uri->getPort(); echo $uri->getPath(); echo $uri->getQuery(); echo $uri->getFragment();
使用Uri工厂
Uri工厂也可以用来创建Uri实例。
use Kusabi\Uri\UriFactory; // Instantiate a Uri instance $factory = new UriFactory(); $uri = $factory->createUri('https://user:pass@www.my-site.com:8080/users/22?filter=name#bottom'); // Fetch the properties of the Uri instance echo $uri->getScheme(); echo $uri->getAuthority(); echo $uri->getUserInfo(); echo $uri->getHost(); echo $uri->getPort(); echo $uri->getPath(); echo $uri->getQuery(); echo $uri->getFragment();