Immutable uri object with validation and helpful methods

Maintainers

👁 XAKEPEHOK

Package info

github.com/PHP-DTO/Uri

pkg:composer/php-dto/uri

Statistics

Installs: 2 980

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2022-11-10 12:53 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause dde9a9d114d24f255789679dfbfeefc84518ffa8

  • Timur Kasumov aka XAKEPEHOK <icq-475204.woop@ya.ru>

uriValue Objectdto

This package is not auto-updated.

Last update: 2026-06-20 04:21:57 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)