PHP code example of rabiloo / laravel-local-temporary-url

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

    

rabiloo / laravel-local-temporary-url example snippets


# config/filesystems.php

return [
    'disks' => [
        // 
        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'throw' => false,
            'serve' => true, // Enable file server, default URL is `/local/temp/{path}?expires=xxx&signature=xxx`
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',   // Enable file server with `visibility` = `public` 
            'throw' => false,
        ],

        // Custom local disk
        'local2' => [
            'driver' => 'local',
            'root' => storage_path('app/local2'),
            'throw' => false,
            'serve' => true,        // Enable file server
            'url' => 'local2/tmp',  // The URL will be `/local2/tmp/{path}?expires=xxx&signature=xxx`
        ],

        //...
    ],
];

use Illuminate\Support\Facades\Storage;

$url = Storage::disk('local')->temporaryUrl($path, now()->addSeconds(120));