蜂巢/core

HoneyComb CMS后端元素包

0.4.15 2019-08-29 10:55 UTC

README

https://github.com/honey-comb/core

描述

HoneyComb CMS Core包,用于后端元素

注意

这是HoneyComb CMS包的一部分核心包。它需要starter包。

如果您想使用laravel版本5.6.* 请使用核心包版本0.3.*

要求

  • php: ^7.1.3
  • laravel: ^5.7
  • composer

安装

首先通过Composer安装此包。

	{
	    "require": {
	        "honey-comb/core": "^0.4"
	    }
	}

或者

    composer require honey-comb/core

Laravel集成

要自定义中间件

  • 在hc.php文件中添加值到ignoreDefaultMiddleware属性以禁用中间件
    'ignoreDefaultMiddleware' => [ ],
  • 手动添加中间件到kernel.php

准备

用户

确保更新config/auth.php中的User控制器

'defaults' => [
    'guard' => 'api',
    'passwords' => 'users',
],
'api' => [
    'driver' => 'passport',
    'provider' => 'users',
],
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => \HoneyComb\Core\Models\HCUser::class,
    ],
],
'passwords' => [
    'users' => [
        'provider' => 'users',
        'table' => 'hc_user_password_reset',
        'expire' => 60,
    ],
],

处理器

确保在app/Exceptions/Handler.php中使用异常处理器特性

<?php

namespace App\Exceptions;

use HoneyComb\Core\Exceptions\Traits\HCExceptionHandlerTrait;

class Handler extends ExceptionHandler
{
    use HCExceptionHandlerTrait;
}

数据库

我们推荐使用utf8mb4_unicode_520_ci校对,因此您可以在config/database.php中更新它

    'collation' => 'utf8mb4_unicode_520_ci'

Passport安装

迁移

  • AppServiceProviderregister()方法中添加\Laravel\Passport\Passport::ignoreMigrations();
  • 发布迁移 php artisan vendor:publish --tag=passport-migrations
  • 将表中的user_id字段更新为uuid,例如$table->integer('user_id'); -> $table->uuid('user_id');
    • oauth_auth_codes
    • oauth_access_tokens
    • oauth_clients

安装

php artisan passport:install

命令

移除默认的Laravel用户迁移(如果是全新项目)

2014_10_12_000000_create_users_table.php
2014_10_12_100000_create_password_resets_table.php

运行Artisan命令

php artisan migrate
php artisan hc:seed
php artisan hc:permissions
php artisan hc:forms
php artisan hc:admin-menu   
php artisan hc:super-admin