Published 7 months ago by cklester
I'm running 'php artisan migrate' after having made an adjustment to accommodate the fix suggested here (https://laravel-news.com/laravel-5-4-key-too-long-error). The exact error is this:
[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'App\Providers\Schema' not found
Please let me know what else I need to do to get this migration working.
In the AppServiceProvider.php, you did not include the necessary use statement at the top of the file.
That defines the namespace path to the Schema class so you can simply call
Schema::defaultStringLength(191); in the boot method.
I'm a beginner, but I must say.. shouldn't this be configured by default? I wouldn't say that this is a big issue, considering that it would take just 2 minutes (or less) to set this up for any new project.
Could someone shed light on this?
Also, thank you, @wells !
@JunTheProgrammer Laravel is a framework where you build different things.
Namespaces is a PHP thing.
Laravel doesn't know which facades/classes you'll ever use. So it isn't 'pre-configured' by default. Not everyone uses
Schema on a ServiceProvider for instance.
A workaround for this is to use an IDE like PHPStorm. It automatically adds the namespace as you type the class name.