【问题标题】:lumen 5.7 dusterio/lumen-passport fails on php artisan migratelumen 5.7dusterio/lumen-passport 在 php artisan 迁移上失败
【发布时间】:2019-04-07 01:03:21
【问题描述】:

创建一个新的 laravel/lumen 5.7 并安装 dusterio/lumen-passport 包并按照那里的说明进行操作后:

我收到以下错误:

在 Connection.php 第 664 行:

SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '' 附近使用正确的语法(SQL:create table migrations (id int unsigned not null auto_increment 主键,migration varchar(255) not null, batch int not null) 默认字符集 utf8mb4 collat​​e 'utf8mb4_unicode_ci' engine = )

在 Connection.php 第 452 行:

SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '' 附近使用正确的语法

这是我的配置文件:

<?php

require_once __DIR__.'/../vendor/autoload.php';

try {
    (new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
    //
}



$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

 $app->withFacades();

 $app->withEloquent();


$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);


 $app->routeMiddleware([
     'auth' => App\Http\Middleware\Authenticate::class,
 ]);



$app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(Dusterio\LumenPassport\PassportServiceProvider::class);



$app->router->group([
    'namespace' => 'App\Http\Controllers',
], function ($router) {
    require __DIR__.'/../routes/web.php';
});

return $app;

我也做过同样的lumen 5.6,效果很好。

请帮忙。

【问题讨论】:

  • 可以分享一下配置文件吗?
  • 我已经包含了配置文件
  • 很奇怪,但看起来engine 没有通过? engine = 也可以尝试注释掉$app-&gt;withFacades();
  • 我试过了,还是不行
  • 您是否尝试过在不安装护照包的情况下安装和迁移表?

标签: php laravel eloquent lumen


【解决方案1】:

由于迁移似乎尝试运行,可能是因为您的数据库服务器不支持utf8mb4,请尝试将您的数据库配置设置为:

            'charset' => 'utf8',

而不是:

            'charset' => 'utf8mb4',

【讨论】:

    猜你喜欢
    • 2016-03-22
    • 2018-11-10
    • 2019-02-26
    • 1970-01-01
    • 2015-08-01
    • 2017-10-12
    • 2019-12-08
    • 2018-11-18
    • 2017-03-03
    相关资源
    最近更新 更多