PHP code example of bentools / uri-factory

1. Go to this page and download the library: Download bentools/uri-factory 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/ */

    

bentools / uri-factory example snippets


use function BenTools\UriFactory\Helper\uri;
$uri = uri('http://www.example.net'); // Will convert to a Psr\Http\Message\UriInterface instance

use function BenTools\UriFactory\Helper\current_location;
$uri = current_location(); // Will convert the current location to a Psr\Http\Message\UriInterface instance

use BenTools\UriFactory\Adapter\GuzzleAdapter;
use BenTools\UriFactory\Adapter\LeagueUriAdapter;
use function BenTools\UriFactory\Helper\current_location;
use function BenTools\UriFactory\Helper\uri;

$uri = uri('http://www.example.net', GuzzleAdapter::factory());
$uri = uri('http://www.example.net', LeagueUriAdapter::factory());

$uri = current_location(GuzzleAdapter::factory());
$uri = current_location(LeagueUriAdapter::factory());



use function BenTools\UriFactory\Helper\canonicalize;
use function BenTools\UriFactory\Helper\uri;

$url = 'http://example.org../foo/../bar/?#baz';
echo canonicalize(uri($url)); // http://example.org/bar/