我从GitHub Link跟踪了zizac/entrust安装教程并遇到了错误:
类名必须是一个有效的对象或在VAR的字符串/ WWW/HTML/laravel_test /供应商/ zizaco /委托/ SRC /命令/ MigrationCommand.php上线86
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');