PHP code example of psecio / uri

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

    

psecio / uri example snippets



\Psecio\Uri\Builder;

// Secret is loaded from a configuration outside of the library
$secret = $_ENV['link_secret'];
$uri = new \Psecio\Uri\Builder($secret);

$data = [
    'foo' => 'this is a test'
];
$url = $uri->create('http://test.com', $data);
// http://test.com?foo=this+is+a+test&signature=90b7ac10b261213f71faaf8ce4008fdbdd037bab7192041de8d54d93a158467f


// Sign the URL: http://foo.com/user?test=1
$url = $uri->create('http://foo.com/user?test=1');


$url = 'http://test.com?foo=this+is+a+test&signature=90b7ac10b261213f71faaf8ce4008fdbdd037bab7192041de8d54d93a158467f';

$valid = $uri->verify($url);
echo 'Is it valid? '.var_export($valid, true)."\n"; // boolean response



$data = [
    'foo' => 'this is a test'
];
$expire = '+10 seconds';
$url = $uri->create('http://test.com', $data, $expire);
// http://test.com?foo=this+is+a+test&expires=1521661473&signature=009e2d70add85d79e19979434e3750e682d40a3d1403ee92458fe30aece2c826