Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ellis22's avatar

QueryException: General error: 1 no such table: categories

  • Laravel Version: 5.7
  • PHP Version: 7.2
  • Database Driver: sqlite
  • Database: memory

All testing on PHPUnit was working completely fine. But when I added View::share in AppServiceProvider then all the PHPUnit tests failed.

AppServiceProvider.php

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        \View::share('categories', \App\Models\Category::all());
    }
}

Error

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: categories (SQL: select * from "categories")

Please guide me, how can I fix this. Where should I call View::share in Laravel app so, all tests should pass.

0 likes
2 replies
Ellis22's avatar

@D9705996 - I have already used this RefreshDatabase, In all tests.

As I said, all tests were passing, but when I used View::share in AppServiceProvider then all tests failed.

I guess, ServiceProvider are not best place to add View::share. So, my question is where should I use View::share in Laravel app.

Please or to participate in this conversation.