【发布时间】:2018-10-24 10:56:40
【问题描述】:
尽管进行了多次搜索,但我还是遇到了 defaultStringLength() 问题。我向你解释我的程序。
在文件夹数据库中-> 2018_10_24_103651_create_devis_table.php 我有那个:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDevisTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('devis', function (Blueprint $table) {
$table->increments('id');
$table->string('firstname');
$table->string('lastname');
$table->string('email');
$table->string('phone');
$table->string('start_adress');
$table->string('end_adress');
$table->text('remarks');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('devis');
}
}
然后,我必须更改文件 AppServiceProvider.php
这是我的修改
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(255);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
之后,我运行下一个命令php artisan migrate,我得到了错误消息的结果 -> 调用未定义的方法 Illuminate\Database\Schema\MySqlBuilder::defaultStringLength()
请问你有什么想法吗? 提前感谢您的回答。
【问题讨论】:
-
Schema::defaultStringLength(191);used @anais_stem -
Jignesh Joisar:即使是问题我也不明白为什么它不起作用???
-
你使用的是什么版本的 laravel
-
@anais_stem 阅读这篇文章laravel-news.com/laravel-5-4-key-too-long-error
-
@Shaielndra Gupta:我有 5.3.8 版
标签: php laravel symfony-1.4