PHP code example of uteq / signature

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

    

uteq / signature example snippets

 
$url = SignatureFacade::make(Action::class, ['email' => '[email protected]'])->get();

class Action 
{
    public function __invoke($payload)
    {
        // Do something      

        return redirect('login');
    }
}

return [
    /*
     * This will be the url Signature will use to handle the actions
     * if the action_route is action the url will for example be https://example.com/action/{key}
     */
    'action_route' => '/action/{key}',
    
    /*
    * Here you can optionaly define the actions, for example: 'action => '\App\SignatureActions\Action'
    * When making a url you can provide the key instead of the class path, 
    * when using the example above it would look like SignatureFacade::make('action', $payload)->get();
    */
    'actions' => [
        
    ]
];

class Action
{
    public function __invoke($payload)
    {
        // from here on you can use the variables in $payload to make the link actually do something;

        return redirect('/login'); // If no return is provided the user will be redirected to "/".
    }

}
bash
php artisan vendor:publish --provider="Uteq\Signature\SignatureServiceProvider" --tag="migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="Uteq\Signature\SignatureServiceProvider" --tag="config"
 php
$urlExample = SignatureFacade::make(Action::class)
    ->payload(['variable_1' => 'information', 'variable_2' => 'even more information'])
    ->expirationDate(now()->addWeek())
    ->password('secretPassword')
    ->oneTimeLink()
    ->get();

$longerKeyUrlExample = SignatureFacade::make(Action::class)
    ->longerKey(64)
    ->group('1234')
    ->get();
    
$customKeyExample = SignatureFacade::make(Action::class)
    ->customKey('veryCoolCustomKey')
    ->get();
bash
php artisan signature:clean