salla's avatar
Level 22

Target class [db.schema] does not exist After upgrading to Laravel 9

After upgrading from Laravel 8 to 9, I get stuck on this error Illuminate\Contracts\Container\BindingResolutionException

Target class [db.schema] does not exist.

at vendor/laravel/framework/src/Illuminate/Container/Container.php:895

any idea the cause and how to fix ? thanks !

0 likes
4 replies
alqahtani's avatar

Could be a cache issue? have you tried php artisan config:cache

pkboom's avatar
// DatabaseServiceProvider
        $this->app->bind('db.schema', function ($app) {
            return $app['db']->connection()->getSchemaBuilder();
        });

It may mean laravel can't get db connection. You might want to see if your db setup is correct.

malsowayegh's avatar

are you using PGSQL? in your config/database.php

        'pgsql' => [
            'driver' => 'pgsql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

change this :

            'schema' => 'public',

to

			'search_path' => 'public'

reference: https://laravel.com/docs/9.x/upgrade#postgres-schema-configuration

BrightXue's avatar

take care the "'aliases' => [" in the config file conf/app.php and ServiceProvider config file related item. those 2 items are must from same namespace.

Please or to participate in this conversation.