To install Media Library Pro in Laravel, follow these steps:
1. Install the base Laravel Media Library package:
composer require "spatie/laravel-medialibrary"
2. If you have a license for Media Library Pro, install the pro version instead:
composer require "spatie/laravel-medialibrary-pro:^5.1.0"
3. Publish the Media Library Pro migrations and run them:
php artisan vendor:publish --provider="Spatie\MediaLibraryPro\MediaLibraryProServiceProvider" --tag="media-library-pro-migrations"
php artisan migrate
4. Add the route macro to your routes file to accept temporary uploads:
php
// routes/web.php
Route::mediaLibrary();
5. Set up the front-end by importing the provided CSS, either through Vite or directly in your Blade/HTML templates.
6. Optionally, schedule the command to automatically delete old temporary uploads:
php
// in app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('media-library:delete-old-temporary-uploads')->daily();
}
The key steps are installing the pro package, publishing and running the migrations, setting up the routes, and integrating the front-end CSS. Make sure to follow the instructions carefully, as some steps may vary depending on your Laravel version.[3][5]
Citations:[1] https://github.com/spatie/laravel-medialibrary-pro-app
[2] https://laracasts.com/discuss/channels/laravel/media-library-pro-installation
[3] https://spatie.be/docs/laravel-medialibrary/v11/installation-setup
[4] https://github.com/spatie/laravel-medialibrary/issues/2193
[5] https://spatie.be/docs/laravel-medialibrary/v11/handling-uploads-with-media-library-pro/installation