Class name must be a valid object or a string
Closed this issue · 16 comments
I am getting error of - Class name must be a valid object or a string
when i try to use it in blade.php
Same here :(
Did you override the configuration?
Could you provide sample code?
Could you provide the complete error message + stack trace?
Same Error!
Can not do anything at controller, not at blade. Any suggestions?
@shohanean please provide some code snippet so I can suggests what is wrong
@shohanean please provide some code snippet so I can suggests what is wrong
there is nothing special code snippet we just following the simple install step - https://github.com/laravolt/avatar#output-as-base64
it just shows that error. with default laravel install and with installed.
If so, could yo provide the full stack trace of the error here?
Yes nothing special code
@shohanean full error message please 😄
I just require the package, then published the vendor.
In my controller which is Called ProfileController.php I added
Use use Avatar;
Then in index method I just tried to echo like this:
echo Avatar::create('Joko Widodo')->toBase64();
Then the error came out!
Error
Class name must be a valid object or a string
In line:
vendor\laravolt\avatar\src\ServiceProvider.php:38
So it is related to config file:
// Initial generator class
'generator' => \Laravolt\Avatar\Generator\DefaultGenerator::class,
Could you confirm that you have that entry in config/laravolt/avatar.php ?
Or, you can check using php artisan tinker
, what is the output of the following code:
config(laravolt.avatar.generator)
I'm having the same issue here.
The output of config('laravolt.avatar.generator')
in tinker is null
Solved by running php artisan config:cache
to clear and rebuild the configuration cache