vish4395 / laravel-file-viewer
A basic file viewer for Laravel projects
Installs: 7 907
Dependents: 0
Suggesters: 0
Security: 0
Stars: 118
Watchers: 3
Forks: 23
Open Issues: 2
Language:JavaScript
Requires
- php: ^7.4|^8.0
- laravel/framework: *
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-05-23 14:34:14 UTC
README
Laravel File Viewer is the easiest way to preview images, videos, audio, PDF, DOCX, PPTX, XLSX, and more in your Laravel app. Instantly add beautiful file previews to your admin panels, dashboards, or user portals.
β¨ Loved by developers. Easy to install. Works out of the box.
π¦ Features
- π Preview images, videos, audio, PDF, DOCX, PPTX, XLSX, and more
- β‘οΈ Super simple integrationβjust one line in your controller!
- π¨ Customizable UI (publish and tweak the views)
- π‘οΈ Secure: works with Laravel's storage disks
- π Multilingual ready
π οΈ Installation
Install via Composer:
composer require vish4395/laravel-file-viewer
Publish assets:
php artisan vendor:publish --provider="Vish4395\LaravelFileViewer\LaravelFileViewerServiceProvider" --tag=assets
Publish views (optional, for UI customization):
php artisan vendor:publish --provider="Vish4395\LaravelFileViewer\LaravelFileViewerServiceProvider" --tag=views
π Quick Start
Add the alias in your config/app.php
(Laravel 10 and below):
'aliases' => Facade::defaultAliases()->merge([ 'LaravelFileViewer' => Vish4395\LaravelFileViewer\LaravelFileViewerFacade::class, ])->toArray(),
Example Controller
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); } }
Add a route in routes/web.php
:
Route::get('/file-preview/{fileName}', [FilePreviewController::class, 'filePreview']);
π Why Laravel File Viewer?
- Save hours: No need to integrate multiple JS libraries yourself.
- Modern UI: Looks great out of the box.
- Flexible: Works with any Laravel storage disk.
- Trusted: Used in production by agencies and startups.
π Help Us Grow!
If you find this package useful:
- β Star this repo on GitHub
- π¦ Try it in your next Laravel project
- π¦ Tweet about it @vish4395
- π¬ Share feedback and suggestions
π Changelog
See CHANGELOG for recent updates.
π€ Contributing
PRs are welcome! See CONTRIBUTING for details. Questions? Email vishal@newai.in or open an issue.
π Security
If you discover any security issues, please email vishal@newai.in instead of using the issue tracker.
π Credits
π License
MIT. See License File for details.