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

[Symfony\Component\Debug\Exception\FatalErrorException] Class 'App\User' not found #40

Closed
happyDemon opened this issue Jan 21, 2016 · 5 comments

Comments

@happyDemon
Copy link

Using laravel 5.1,
some classes in your Database namespace expect App\User to be present in my installation.

However, my app namespace is different and my models were put in to a folder called 'Models' under the app namespace.

I see that you're just using it as a reference to load the actual user model class. Wouldn't it be better to just use a string instead of a reference.

A lot of applications won't have it present in the App namespace and/or have it available at the top of that namespace.

@jonagoldman
Copy link

You should read the repo issues first: #21. Although not sure this is exactly your problem.
The conclusion of that issue is that because ClassName::class magically evaluates as "ClassName", without triggering autoloading of that class, you don't get the Class App\User does not exist error even if the class does not exist. I hope next versions of PHP follow this rule so nothing breaks in the future. Because of that I'm not sure why your are getting the error. Are you sure its related to Bouncer or maybe just something in your Laravel's config file? And also provide error stack trace so it's possible to understand wheres the error coming from.

@happyDemon
Copy link
Author

This is the exact stacktrace I'm getting:
[2016-01-21 13:18:40] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'App\User' not found' in /Users/maximkerstens/Desktop/projects/xarona-app/vendor/silber/bouncer/src/Database/Models.php:105
Stack trace:
#0 {main}

when I correct it to the correct namespace manually, there's no error

My auth.model config has been pointing to the correct model all this time

@JosephSilber
Copy link
Owner

@happyDemon when you change the User model's location, you have to let Laravel's auth system know about it.

Bouncer will use that information to correctly get the model.

Which version of Bouncer are you using?

@JosephSilber
Copy link
Owner

@happyDemon has this been fixed? If not, can you please provide more information about your isuue?

@happyDemon
Copy link
Author

It's been fixed, I'm completely baffled why it didn't give an error the second time I installed.
User model's path was correctly filled in for laravel's auth system.
oh well, works now

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

3 participants