Laravel Tinker error with SQLite database

174 Views Asked by At

Starting from a fresh project:

laravel new new-project
cd new-project
touch storage/database/database.sqlite

Then at .env

DB_CONNECTION=sqlite
DB_DATABASE=storage/database/database.sqlite
DB_FOREIGN_KEYS=true

The migration succeed...

php artisan migrate
php artisan tinker
>>>App\User::all()

But when I try to get all users it returns the following error:

PHP Fatal error:  Class 'App/User' not found in Psy Shell code on line 1

What I could be missing?

2

There are 2 best solutions below

0
On

Recently I reinstalled Laravel...

And I didn't realized I was using version Laravel 8 the models are at /app/Models

So the right command would be:

>>>App\Models\User::all()
0
On

i think it has something to do with the namespace alias. Try without the App/

Users::all();