Summer Sale! All accounts are 50% off this week.

earmsby's avatar

trouble installing Spatie Media Library

I have a Filament 4.x app and I'm trying to add the Spatie Media Library. When I run:

composer require filament/spatie-laravel-media-library-plugin:"^5.0" -W

The installation fails with this error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires filament/spatie-laravel-media-library-plugin 5.0 -> satisfiable by filament/spatie-laravel-media-library-plugin[v5.0.0].
    - filament/spatie-laravel-media-library-plugin v5.0.0 requires filament/support v5.0.0 -> found filament/support[v5.0.0] but these were not loaded, likely because it conflicts with another require.

I'm on Windows using powershell, so I tried changing the command to:

composer require filament/spatie-laravel-media-library-plugin:"~5.0" -W

but I still got an error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires filament/spatie-laravel-media-library-plugin ~5.0 -> satisfiable by filament/spatie-laravel-media-library-plugin[v5.0.0, ..., v5.6.8].
    - filament/spatie-laravel-media-library-plugin v5.0.0 requires filament/support v5.0.0 -> found filament/support[v5.0.0] but these were not loaded, likely because it conflicts with another require.
[plus many more lines for higher versions]

I'm wondering if the problem is that I'm installing v. 5 of the plug-in but I'm on filament v. 4?

0 likes
2 replies
LaryAI's avatar
Level 58

You're exactly right: the source of the problem is a version mismatch between the Filament Spatie Media Library Plugin and your installed Filament core packages.

filament/spatie-laravel-media-library-plugin v5.x is only compatible with Filament v5.x.
If your app is using Filament 4.x, you need to use filament/spatie-laravel-media-library-plugin v4.x.


Solution

  1. Check your current Filament version

    Run:

    composer show filament/filament
    

    This will show something like versions : * 4.x.x

  2. Install the matching plugin version

    For Filament 4.x, install the v4 version of the plugin:

    composer require filament/spatie-laravel-media-library-plugin:"^4.0"
    

    Do not use v5 of the plugin if your core Filament is v4.


Notes

  • If you want to use v5 of the plugin, you'd have to upgrade Filament to v5, but this can involve breaking changes.
  • The error you saw:
    filament/spatie-laravel-media-library-plugin v5.0.0 requires filament/support v5.0.0
    
    means it's looking for Filament 5 core packages, which do not exist in your project.

General advice

For all Filament plugins, always check the plugin's composer.json or documentation for support matrix (which core Filament versions are compatible with which plugin versions).


Summary:
Downgrade the Filament Spatie Media Library Plugin to ^4.0 to fit your Filament 4.x installation:

composer require filament/spatie-laravel-media-library-plugin:"^4.0"

That should solve the installation conflict!

earmsby's avatar
earmsby
OP
Best Answer
Level 7

In case anyone else runs into this, the command that worked was:

composer require filament/spatie-laravel-media-library-plugin:"~4.0" -W

Please or to participate in this conversation.