typidesign / laravel-media-validator
A Laravel validator for audio and video files.
Requires
- php: ^7.0|^8.0
- illuminate/support: ~5.5|~6.0|~7.0|~8.0|~9.0
- php-ffmpeg/php-ffmpeg: ^0.14.0
README
This package gives your Laravel app a validator for audio and video files based on the information returned by ffprobe, wich is part of the FFmpeg project.
Why this package?
Because Symfony’s MIME types guessing is often not reliable, especially for audio files (see symfony/symfony#8678).
Installation
First install ffmpeg:
- On Debian/Ubuntu, run
sudo apt install ffmpeg
- On macOS with Homebrew:
brew install ffmpeg
Then you can install the package via composer:
composer require typidesign/laravel-media-validator
Usage
In your controller or anywhere you validate your data, add this rule:
$request->validate([ 'audio' => [ new IsAudio(['mp3', 'aac']), // … ], ]);
or this, for videos:
$request->validate([ 'audio' => [ new IsVideo(['h264', 'theora']), // … ], ]);
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email samuel@typidesign.be instead of using the issue tracker.
Credits
About Typi Design
Typi Design is a webdesign agency based in Brussels, Belgium.
License
The MIT License (MIT). Please see License File for more information.