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 trial

PHP Laravel Basics MVC (Model) Deploying Migrations

Marco Claassen
Marco Claassen
3,475 Points

PHP 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

I seemed to have fixed this issue by adding use App\Models\Course; to AppController.php on Laravel version 8.

yes, 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
Elinor Armsby
13,663 Points

Thank you! I was pulling my hair out until I found this.

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi 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! :sparkles: