簡體   English   中英

如何修復laravel 5.2 zizaco委托:遷移類名稱驗證?

[英]How to fix in laravel 5.2 zizaco entrust:migration class name validation?

我從GitHub Link跟蹤了zizac / entrust安裝教程並遇到了錯誤:

類名必須是第86行的var / www / html / laravel_test / vendor / zizaco / entrust / src / commands / MigrationCommand.php中的有效對象或字符串

MigrationCommand.php文件網址: 鏈接

Outut:

php artisan entrust:migration

Tables: roles, role_user, permissions, permission_role
A migration that creates 'roles', 'role_user', 'permissions', 'permission_role' tables will be created in database/migrations directory

Proceed with the migration creation? [Yes|no] (yes/no) [yes]: yes

Creating migration...
PHP Fatal error:  Class name must be a valid object or a string in /var/www/html/laravel_test/vendor/zizaco/entrust/src/commands/MigrationCommand.php on line 86

命令: php artisan vendor:發布成功。

文件:config / entrust.php存在。

我沒有改變config / auth.php文件的任何選項 - auth.php 怎么解決?

在第86行的vendor / zizaco / entrust / src / commands / MigrationCommand.php中

刪除行:

    $usersTable  = Config::get('auth.table');
    $userModel   = Config::get('auth.model');

添加行:

$usersTable  = Config::get('auth.providers.users.table');
$userModel   = Config::get('auth.providers.users.model');

和config / auth.php文件一樣寫提供者行,就像我一樣:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
        'table' => 'users',
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

然后你的問題將解決:快樂的編碼

在第86行的vendor / zizaco / entrust / src / commands / MigrationCommand.php中。

Laravel 5.1。*添加行

$usersTable  = Config::get('auth.table');
$userModel   = Config::get('auth.model');

Laravel 5.2。*添加線

$usersTable  = Config::get('auth.providers.users.table');
$userModel   = Config::get('auth.providers.users.model');

接受的答案可能會解決問題,但編輯直接供應商文件是非常糟糕的做法。 以下內容將解決您可能遇到的問題,並且如果您決定更新Entrust並修復其代碼庫,則會支持您的應用仍然有效。

將以下行添加到下面的config / auth.php

/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/

Laravel 5.1 - 5.4

'model' => \App\Models\User::class,
'table' => 'users',

一旦Entrust推出更新,您可以將其刪除或保留。 由你決定。

試試跑步:

php artisan config:cache

確保您的應用程序使用新的配置文件

編輯

好的,現在我明白了,這個庫想要使用:

  $usersTable  = Config::get('auth.table');
  $userModel   = Config::get('auth.model');

但是在auth沒有這樣的東西了。

因此,作為臨時解決方法,您應該將tablemodel添加到auth文件中,如下所示: https//github.com/laravel/laravel/blob/5.1/config/auth.php

並等待Entrust升級以刪除它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM