codeinc / url
1.5.4
2018-12-05 11:22 UTC
Requires
- php: >=7.1
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ^7
README
这是一个用于操作URL的PHP 7库。此库通过PSR-7 UriInterface
与Psr7Url
和Psr7ServerUrl
类兼容。
用法
<?php use CodeInc\Url\Url; // parsing a URL $url = Url::fromString("https://www.google.com/?q=A+great+search"); if (isset($url->getQueryAsArray()["p"])) { echo $url->getQueryAsArray()["p"]; } // building a URL $url = (new Url()) ->withHost("www.google.com") ->withoutScheme("https") ->withQuery(["q", "A great search"]); echo $url; // getting the current URL $currentUrl = Url::fromGlobals(); ## Tests A unit test is available for the [`Url`](src/Url.php) class in the [`UrlTest`](tests/UrlTest.php) class. To run the tests using [PHPUnit](https://phpunit.de/): ```bash ./vendor/bin/phpunit tests/UrlTest.php
安装
此库可通过Packagist获取,并可以使用Composer进行安装。
composer require codeinc/url
许可证
该库在MIT许可证下发布(请参阅LICENSE
文件)。