Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMarco Claassen
3,475 PointsPHP Error: Class 'Course' not found in Psy Shell code on line 1
After following all the steps in the video. Everything works untill I get to Course::all(); in Tinker, where I'm presented with: "PHP Error: Class 'Course' not found in Psy Shell code on line 1".
I've tried to find an answer online, but no luck so far. Things I've tried:
- Changing the use App\Course; to App\Models\Course;
- "composer dump-autoload"
- Running migrate and db:seed again.
- Deleting the database and creating a new one.
- Restore a back-up and going through all the actions in this course again
I's there anything I might be missing? I'm running Laravel 8.18.1
3 Answers
robert fraser
31,236 PointsI seemed to have fixed this issue by adding use App\Models\Course; to AppController.php on Laravel version 8.
Martin Valdivia
946 Pointsyes, it is fixed by changing 'App\Course' with 'App\Models\Course', but if still not working, please exit Tinker and run composer dump-autoload, then enter tinker again: 'php artisan tinker' and try 'Course::all()' again.
I'm using Laravel 10.9.0
Elinor Armsby
13,987 PointsThank you! I was pulling my hair out until I found this.
Jennifer Nordell
Treehouse TeacherHi there, Marco Claassen! It seems like you might have missed this instruction step as you are running a different and non-LTS version of Laravel.
Hope this helps!