PHP code example of yaroslawww / laravel-temporal-key

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

    

yaroslawww / laravel-temporal-key example snippets


$schedule->command('temporal-key:prune')->everyTenMinutes();

$key = \TemporalKey\Manager\TmpKey::create()->key()
// Customize default expiration datetime
$key = \TemporalKey\Manager\TmpKey::create(validUntil: \Carbon\Carbon::now()->addDay())->key()
// Add metadata
$key = \TemporalKey\Manager\TmpKey::create(['email' => '[email protected]'])->key()
// Customise custom maximal retrieve count.
$key = \TemporalKey\Manager\TmpKey::create(usageMax: 22)->key()

$temporalKey = \TemporalKey\Manager\TmpKey::find('testkey');

$temporalKey?->key();
$temporalKey?->meta();

use TemporalKey\Manager\TmpKey;

class ImagePreviewTmpKey extends TmpKey
{
    public static string $type = 'image-preview';
    public static int $defaultValidSeconds = 60 * 60;
    public static int $defaultUsageMax = 0; // unlimited
}

$key = ImagePreviewTmpKey::create()->key()
$temporalKey = ImagePreviewTmpKey::find('testkey');
shell
php artisan vendor:publish --provider="TemporalKey\ServiceProvider" --tag="config"
shell
php artisan migrate