php-dto / uri
Immutable uri object with validation and helpful methods
Installs: 1 462
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
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-11-08 20:30:58 UTC
README
Installation
composer require php-dto/uri
Usage
<?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)