php-dto / uri
具有验证和有用方法的不可变URI对象
0.1.0
2022-11-10 12:53 UTC
Requires
- php: >=7.4.0
- ext-json: *
- league/uri: 6.7.*
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-13 19:51:43 UTC
README
安装
composer require php-dto/uri
用法
<?php $uri = new \PhpDto\Uri\Uri('https://foo@test.example.com:42?query#'); echo $uri->get(); //will print https://foo@test.example.com:42?query# echo (string) $uri; //will print https://foo@test.example.com:42?query# print_r($uri->getComponents()); //will print array( 'scheme' => 'https', // the URI scheme component 'user' => 'foo', // the URI user component 'pass' => null, // the URI pass component 'host' => 'test.example.com', // the URI host component 'port' => 42, // the URI port component 'path' => '', // the URI path component 'query' => 'query', // the URI query component 'fragment' => '', // the URI fragment component ); new \PhpDto\Uri\Uri('http://test.com', ['https',]); //will throw \PhpDto\Uri\Exception\UriException (allows only `https` scheme)