PHP code example of vish4395 / laravel-file-viewer

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

    

vish4395 / laravel-file-viewer example snippets


'aliases' => Facade::defaultAliases()->merge([
    'LaravelFileViewer' => Vish4395\LaravelFileViewer\LaravelFileViewerFacade::class,
])->toArray(),

use Illuminate\Http\Request;
use Vish4395\LaravelFileViewer\LaravelFileViewer;

class FilePreviewController extends Controller
{
    public function filePreview($fileName){
        $filePath = $fileName;
        $disk = 'public';
        $fileUrl = asset('storage/' . $fileName);
        $fileData = [
            [
                'label' => __('Label'),
                'value' => "Value"
            ]
        ];
        return LaravelFileViewer::show($fileName, $filePath, $fileUrl, $disk, $fileData);
    }
}

Route::get('/file-preview/{fileName}', [FilePreviewController::class, 'filePreview']);
bash
php artisan vendor:publish --provider="Vish4395\LaravelFileViewer\LaravelFileViewerServiceProvider" --tag=assets
bash
php artisan vendor:publish --provider="Vish4395\LaravelFileViewer\LaravelFileViewerServiceProvider" --tag=views