Laravel-medialibrary: Error when installing

Created on 18 Nov 2019  路  4Comments  路  Source: spatie/laravel-medialibrary

Hello, i'm getting an error when i'm trieing to install the package:

Class name must be a valid object or a string

at C:\xampp\htdocs\powerproject\vendor\spatie\laravel-medialibrary\src\MediaLibraryServiceProvider.php:33
29| ], 'views');
30|
31| $mediaClass = config('medialibrary.media_model');
32|

33| $mediaClass::observe(new MediaObserver());
34|
35| $this->loadViewsFrom(__DIR__.'/../resources/views', 'medialibrary');
36| }
37|

Exception trace:

1 Spatie\MediaLibrary\MediaLibraryServiceProvider::boot()
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32

2 call_user_func_array([])
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32

Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json to its original content.

Most helpful comment

Hello, i'm getting an error when i'm trieing to install the package:
Class name must be a valid object or a string
at C:\xampp\htdocs\powerproject\vendor\spatie\laravel-medialibrary\src\MediaLibraryServiceProvider.php:33
29| ], 'views');
30|
31| $mediaClass = config('medialibrary.media_model');
32|

33| $mediaClass::observe(new MediaObserver());
34|
35| $this->loadViewsFrom(DIR.'/../resources/views', 'medialibrary');
36| }
37|

Exception trace:
1 Spatie\MediaLibrary\MediaLibraryServiceProvider::boot()
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
2 call_user_func_array([])
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.

go to bootstrap/cache and delete config.php, packages.php services.php.
Then install an older version of the library.
I installed 7.14.0 and it works

Been having the same issue and this worked.

In case future readers don't know, the way to install specific packages versions is by removing the '^', like this:

composer require "spatie/laravel-medialibrary:7.14.0"

All 4 comments

Hello guys. I'm also having this same issue. Composer revert didn't work and I'm stuck.

Hello, i'm getting an error when i'm trieing to install the package:

Class name must be a valid object or a string

at C:\xampp\htdocs\powerproject\vendor\spatie\laravel-medialibrary\src\MediaLibraryServiceProvider.php:33
29| ], 'views');
30|
31| $mediaClass = config('medialibrary.media_model');
32|

33| $mediaClass::observe(new MediaObserver());
34|
35| $this->loadViewsFrom(DIR.'/../resources/views', 'medialibrary');
36| }
37|

Exception trace:

1 Spatie\MediaLibrary\MediaLibraryServiceProvider::boot()
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32

2 call_user_func_array([])
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32

Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json to its original content.

go to bootstrap/cache and delete config.php, packages.php services.php.
Then install an older version of the library.
I installed 7.14.0 and it works

Hello, i'm getting an error when i'm trieing to install the package:
Class name must be a valid object or a string
at C:\xampp\htdocs\powerproject\vendor\spatie\laravel-medialibrary\src\MediaLibraryServiceProvider.php:33
29| ], 'views');
30|
31| $mediaClass = config('medialibrary.media_model');
32|

33| $mediaClass::observe(new MediaObserver());
34|
35| $this->loadViewsFrom(DIR.'/../resources/views', 'medialibrary');
36| }
37|

Exception trace:
1 Spatie\MediaLibrary\MediaLibraryServiceProvider::boot()
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
2 call_user_func_array([])
C:\xampp\htdocs\powerproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.

go to bootstrap/cache and delete config.php, packages.php services.php.
Then install an older version of the library.
I installed 7.14.0 and it works

Been having the same issue and this worked.

In case future readers don't know, the way to install specific packages versions is by removing the '^', like this:

composer require "spatie/laravel-medialibrary:7.14.0"

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ideadx picture ideadx  路  4Comments

amrnn90 picture amrnn90  路  3Comments

Krato picture Krato  路  4Comments

jam1e picture jam1e  路  3Comments

brendt picture brendt  路  4Comments