Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class name must be a valid object or a string #105

Closed
hemant17 opened this issue May 12, 2020 · 16 comments
Closed

Class name must be a valid object or a string #105

hemant17 opened this issue May 12, 2020 · 16 comments

Comments

@hemant17
Copy link

I am getting error of - Class name must be a valid object or a string
when i try to use it in blade.php

@sectorf8
Copy link

Same here :(

@uyab
Copy link
Contributor

uyab commented May 13, 2020

Did you override the configuration?
Could you provide sample code?
Could you provide the complete error message + stack trace?

@shohanean
Copy link

Same Error!

@shohanean
Copy link

Can not do anything at controller, not at blade. Any suggestions?

@uyab
Copy link
Contributor

uyab commented May 28, 2020

@shohanean please provide some code snippet so I can suggests what is wrong

@hemant17
Copy link
Author

@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.

@uyab
Copy link
Contributor

uyab commented May 28, 2020

If so, could yo provide the full stack trace of the error here?

@shohanean
Copy link

Yes nothing special code

@uyab
Copy link
Contributor

uyab commented May 29, 2020

@shohanean full error message please 😄

@shohanean
Copy link

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!

@shohanean
Copy link

Error
Class name must be a valid object or a string

@shohanean
Copy link

In line:
vendor\laravolt\avatar\src\ServiceProvider.php:38

@uyab
Copy link
Contributor

uyab commented May 30, 2020

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)

@dieume-n
Copy link

dieume-n commented Jun 30, 2020

I'm having the same issue here.

The output of config('laravolt.avatar.generator') in tinker is null

@dieume-n
Copy link

Solved by running php artisan config:cache to clear and rebuild the configuration cache

@kb6673
Copy link

kb6673 commented Sep 4, 2020

I solved this just like @dieume-n .

Perhaps the documentation should remind us to rebuild the config cache.

@uyab uyab pinned this issue Sep 10, 2020
@uyab uyab closed this as completed Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants