laravel admin 后台配置总结
-
composer 安装 encore/laravel-admin
-
地址:https://packagist.org/packages/encore/laravel-admin
-
中文文档:http://laravel-admin.org/docs/#/
-
命令:
composer require encore/laravel-admin
php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"
php artisan admin:install
注意:mysql 数据需要MySql 5.5.3以上,支持utf8mb4,安装第三步骤会报错:
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email)) [PDOException]SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
解决方法就是:手动配置迁移命令migrate
生成的默认字符串长度,在AppServiceProvider
中调用Schema::defaultStringLength
方法来实现配置:
use Illuminate\Support\Facades\Schema; /** * Bootstrap any application services. * * @return void */ public function boot(){ Schema::defaultStringLength(191); }
最后后台地址:http://localhost/admin 用户名:admin 密码:admin
生成admin下controller
php artisan admin:make ArticleController –model=App\\Model\\Article