user3468312
user3468312

Reputation: 49

Class 'Illuminate\Support\facades\Schema' not found

I am working with Laravel5.4. When I use socialite package to login with Facebook, I need to add this line of

Schema::defaultStringLength(191);

to boot function of AppServiceProvider class in order to create default password for new user.

Beside that I have to add using statement at top of AppServiceProvider class like this

use Illuminate\Support\facades\Schema;

Everything is working well on my localhost but when I upload all code to my share hosting, I get this error

Class 'Illuminate\Support\facades\Schema' not found.

Can anyone help me on this. I am highly appreciated your help!

Upvotes: 0

Views: 13894

Answers (9)

Darwin Quiñones
Darwin Quiñones

Reputation: 29

In my case, I just closed Visual Studio Code, and all the terminals, then ran the server again. It worked perfectly for me.

Upvotes: 0

Pejman Zeynalkheyri
Pejman Zeynalkheyri

Reputation: 4812

I have the same problem with my Laravel 8.40 and PHP 7.4.

So for solving the problem I changed the facades to capital Facades in my AppServiceProvider.php file at this path app/Providers/AppServiceProvider.php on line 6:

use Illuminate\Support\facades\Schema;

To

use Illuminate\Support\Facades\Schema;

Upvotes: 0

user3468312
user3468312

Reputation: 49

OMG I follow the marked answer of question below and replace the using statement with

use Schema;

and the error gone. But I still don't know why it works well on local and only cause error on server.

Method 'create' not found in class Illuminate\Support\Facades\Schema

Upvotes: 4

Jivan Gautam
Jivan Gautam

Reputation: 21

In my case, I use capital letter its work.

use Illuminate\Support\facades\Schema;

replace with this

use Illuminate\Support\Facades\Schema;

Upvotes: 2

OKAN AKGÖZ
OKAN AKGÖZ

Reputation: 1

You must set the .env file This setting

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ilk
DB_USERNAME=root
DB_PASSWORD=

in app/Providers/AppServiceProvider.php

n

amespace App\Providers;

use Illuminate\Support\ServiceProvider;
//hata almamak ıcın
use Illuminate\Support\Facades\Schema;


class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
      Schema::defaultStringLength(191);
     }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

Upvotes: -1

aeroforce
aeroforce

Reputation: 31

Fix Capitalize Error and replace:

use Illuminate\Support\facades\Schema;

with

use Illuminate\Support\Facades\Schema;

The reason it might work on local and not work on server is that probably you're using windows locally, and Linux hosting account which is case-sensitive regarding the paths and filenames

Upvotes: 3

Fredrick Boaz
Fredrick Boaz

Reputation: 169

Replace this line:

use Illuminate\Support\facades\Schema;

With this:

use Schema;

Upvotes: 1

kangular
kangular

Reputation: 263

Maybe you need to change use Illuminate\Support\facades\Schema;

to

use Illuminate\Support\Facades\Schema;

Facades needs to capital F

Upvotes: 1

Akash Sethi
Akash Sethi

Reputation: 324

I was facing the same error when i hosted website .

Class 'Illuminate\Support\facades\Schema' not found.

then i just replaced use Illuminate\Support\facades\schema; with use Illuminate\Support\Facades\Schema;

Upvotes: 1

Related Questions