PHP code example of rekalogika / temporary-url-bundle

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

    

rekalogika / temporary-url-bundle example snippets


use Rekalogika\TemporaryUrl\Attribute\AsTemporaryUrlServer;
use Rekalogika\TemporaryUrl\TemporaryUrlGeneratorInterface;
use Symfony\Component\HttpFoundation\Response;

class MyData
{
    public string $name = 'John Doe';
}

class MyDataServer
{
    #[AsTemporaryUrlServer]
    public function respond(MyData $data): Response
    {
        return new Response('My name is ' . $data->name);
    }
}

/** @var TemporaryUrlGeneratorInterface $temporaryUrlGenerator */

$myData = new MyData;
$myData->name = 'Jane Doe';
$url = $temporaryUrlGenerator->generateUrl($myData);