PHP code example of psx / uri

1. Go to this page and download the library: Download psx/uri library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

psx / uri example snippets




$uri = Uri::parse('/bar?foo=bar');

$uri->getPath(); // /bar
$uri->getQuery(); // foo=bar
$uri->getParameters(); // ['foo' => 'bar']

$uri = $uri->withScheme('https');
$uri = $uri->withScheme('foo.com');

echo $uri->toString(); // https://foo.com/bar?foo=bar

// the url object validates whether a scheme and host is available thus it is a valid url
$url = Url::parse($uri->toString());

// a urn provides additional getter to get the urn specific components. A urn must start with urn:
$urn = Urn::parse('urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66');

$urn->getNid(); // uuid
$urn->getNss(); // 6e8bc430-9c3a-11d9-9669-0800200c9a66