I just started to learn Laravel 5.4 and trying to migrate a users table in Laravel. When I run my migration I get this error:
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
After following this tutorial, I now have another error:
PHP Fatal error: Class 'App\Providers\ServiceProvider' not found
My migration code is
use Illuminate\Support\Facades\Schema;
public function boot()
{
//
Schema::defaultStringLength(191);
}
What am I doing wrong?
Best Answer
The problem is that you are missing the
use
statement that identifies where theServiceProvider
class is. Since theAppServiceProvider
class extendsServiceProvider
, but there is nouse
statement, PHP assumes that the class can be found in the same namespace asAppServiceProvider
. This is why it can't find\App\Providers\ServiceProvider
- because\App\Providers
is the namespace of theAppServiceProvider
class.Try this