项目创建

一、创建项目和基本设置

$ cd /var/www/html
$ laravel new mes
$ chmod -R 777 storage
$ chmod -R 777 bootstrap/cache

mes is short for Manufacturing execution systems

二、安装 Entrust

2.1 在 composer.json 中加入 "zizaco/entrust": "5.2.x-dev",然后运行命令 composer update
2.2 在 config/app.php 中加入 providers 和 aliases

Zizaco\Entrust\EntrustServiceProvider::class,
'Entrust'   => Zizaco\Entrust\EntrustFacade::class,

2.3 拷贝相关文件

$ php artisan vender:publish

执行以下动作

Copied Directory [/vendor/laravel/framework/src/Illuminate/Notifications/resources/views] To [/resources/views/vendor/notifications]
Copied Directory [/vendor/laravel/framework/src/Illuminate/Pagination/resources/views] To [/resources/views/vendor/pagination]
Copied File [/vendor/zizaco/entrust/src/config/config.php] To [/config/entrust.php]
Copied Directory [/vendor/laravel/framework/src/Illuminate/Mail/resources/views] To [/resources/views/vendor/mail]
Publishing complete.

三、修改 Model 目录

$ mkdir app/Models
$ mkdir app/Models/User
$ mv app/User.php app/Models/User

修改 app/Models/User/User.php 的命名空间: namespace App\Models\User;
修改 config/auth.php 的模型: 'model' => App\Models\User\User::class,
修改 config/entrust.php 的模型:'role' => 'App\Models\User\Role', 'permission' => 'App\Models\User\Permission',

你可能感兴趣的:(项目创建)