PHP code example of germania-kg / mergequery_urifactory

1. Go to this page and download the library: Download germania-kg/mergequery_urifactory 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/ */

    

germania-kg / mergequery_urifactory example snippets



use Germania\MergeQueryUriFactory\MergeQueryUriFactoryDecorator;
use Nyholm\Psr7\Factory\Psr17Factory;  

$decoratee = new Psr17Factory();
$uri_factory = new MergeQueryUriFactoryDecorator( $decoratee );

// You know the UriFactoryInterface:
$uri = $uri_factory->createUri( 'http://httpbin.org' );

// Programmatically merge query parameters,
// either to a string or UriInterface:
$uri2 = $uri_factory->createUriMergeQuery( 'http://httpbin.org', ['foo' => 'bar']);
$uri3 = $uri_factory->createUriMergeQuery( $uri, ['foo' => 'bar']);

echo $uri3;
// http://httpbin.org?foo=bar