承接 ohhink/rrm 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ohhink/rrm

Composer 安装命令:

composer require ohhink/rrm

包简介

Laravel RBAC based on Laravel-Permission with backend UI

README 文档

README

standard-readme compliant

English 中文

This Package is used for rules controller which based on roles

This package is based on Laravel Permission and can build a rule controller panel with UI in few minutes.

Server Requirements:

  1. Php >= 7.2
  2. Laravel Version >= 6.1 && < 7.0 (Not Support for Laravel Version >= 7.0 , will update soon)

what include

Const

The rule in this novel can be regards as route in Laravel

Why I do this

Word is cheap , show me the code !

Laravel Permission is a very good package without UI. So, this package is add UI on the laravel permission package and do some things to make the panel can be built quickly

What Include:

  1. Rule controller based on Role , you can add more than one roles to a user .
  2. Add more than one rules to a role .
  3. Menus can be different as it depends on the rules the user have .
  4. Write your new rules in the routes/web.php and it can be add in the program through one button
  5. Record the operation, you can choose to use job to do it sync/async
  6. Backend ui panel
  7. Google Authenticator

Installation

Recommend to use new Laravel Project Remember to open execshell_execproc* functions in php.ini

Update the local configure file .env

# change database and key
# change cache
CACHE_DRIVER=redis
REDIS_CLIENT=predis
# suggest
QUEUE_CONNECTION=redis
# google authenticator
GOOGLE_AUTHENTICATOR=false

Run the command in the root of your new laravel project with composer

$ composer require ohhink/rrm

Publish the files , which include admin.php,filesystems.php,permission.php and front resource files and database seeds files

$ php artisan vendor:publish
# if you want to reload latest package seeder, run this command in force. It will remove the origin seeder , so please be careful
$ php artisan vendor:publish --tag=seeds --force

Build the database and run the seeder

# run autoload first to update the userseeder
$ composer dump-autoload
$ php artisan migrate:refresh --seed
$ php artisan db:seed --class=RrmDatabaseSeeder 

Give folder right and soft-link

$ chmod -R 777 storage
$ php artisan storage:link

If you want to use Google Authenticator, you have to add this provider and aliases by yourself

// config/app.php

'providers' => [
    //........
    Earnp\GoogleAuthenticator\GoogleAuthenticatorServiceprovider::class,
    SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class,
],

'aliases' => [
     //..........
    'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class
],

That's it !

How to use

  • The default of the backend route is /admin, this can be change though the config/admin.php The seeder have already make a super admin user , which account is below

    account : admin@gmail.com
    password : admin&%@cv..
  • What's RBAC talk about is , assign one or more rules to a role and assign one or more roles to a user. We can controller rules with a role , which we normally do rather than a detail rule. So , there is few steps you have to do with your business logic

    1. finish your code and add your routes in the route/web.php like you normally do
    2. click the Route Reload . For example , we get the new route admin.test
    3. create or update your translate files in the path resources/vendor/rrm/zh-cn/permission.php
    4. assign this new route to a role , like admin
    5. if this new route is a menu function, you should create a new menu and rebuild the menu otherwise the new menu will not display
  • If you want to rewrite the route , you should add below to you route/web.php

    # this is rewrite the route to your app/Http/Controllers/IndexController.php index()
    
    Route::prefix(config('admin.prefix'))->middleware([
        'auth',
        'admin'
    ])->name('admin.')->group(function () {
        Route::get('/', 'IndexController@index')->name('index');
    });
    

    In your app/Http/Controllers/IndexController.php file ,you should add below

    
    public function index()
    {
        // put your code here !!!
        // recover the view in /resources/views/vendor/rrm/admin/index.blade.php
        // OR you can just run command below, it will create blade files automatically
        // php artisan vendor:publish --tag=views --force
        return view('rrm::admin.index');
    }
    
  • To see the online-user in the right bar , you have to add command in the app/Console.Kernel.php file, like this

    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
        $schedule->command('admin-tool:cache-online-users')->everyMinute();
    }
    

    And Remember To Add Command In Your Server

    * * * * * php /home/vagrant/blade_package/artisan schedule:run >> /dev/null 2>&1
    
  • Since it record every step user did on panel, if you want to do it async, you can change the key val QUEUE_CONNECTION=sync in .env files to QUEUE_CONNECTION=redis This will make the recorder use jobs to async log the operations which will be faster. Of course you have to add Redis or PRedis package first

  • If you want to change 500 page, you can create a resource/views/vendor/rrm/500.blade.php to rewrite that.

  • Listen Queue Command

    php artisan queue:work --queue=logs --sleep=3 --tries=3
    
    # prefer to use supervisor
    # supervisor config file -- laravel-worker.conf
    
    [program:logs]
    process_name=%(program_name)s_%(process_num)02d
    command=php path_to/artisan queue:work --queue=logs --sleep=3 --tries=3
    autostart=true
    autorestart=true
    user=root
    numprocs=2
    redirect_stderr=true
    stdout_logfile=path_to/supervisor/logs.log
    
    save and run ** supervisorctl reload ** to reload it
    
  • The layout of this package, you can use it though the follow code.

     @extends('rrm::admin.layout')
     
     @section('content')
         <section id="main-content">
             <section class="wrapper">
                 @if (Session::has('success'))
                     @include('rrm::admin.layout.success',['msg'=>Session::get('success')])
                 @endif
                 @if (Session::has('error'))
                     @include('rrm::admin.layout.error',['msg'=>Session::get('error')])
                 @endif
                 <div class="row">
                     <div class="col-lg-12">
     
                     </div>
                 </div>
             </section>
         </section>
     @endsection
     
     @section('js')
     @endsection
     @section('css')
     @endsection
    
  • Use Google Authenticator

    # First , add config to the file .env
    GOOGLE_AUTHENTICATOR=true
    
    # After that, no matter which page the user going to visit , he will redirect to GOOGLE AUTHENTICATOR PAGE. 
    # Follow the step and it will redirect to the normal page after register.
    # If you what to vertify in your code , you can learn from the fake code.
    public function index()
    {
         // $google code which is  registered before 
         // $vertify code to be verified
         if (\OhhInk\Rrm\Model\Google::CheckCode($google, $vertify)) {
                 // pass
         } else {
                 // fail
         }
    }
    

Related Efforts

Maintainers

@OhhInk.

Contributing

Feel free to dive in! Open an issue or submit PRs.

Standard Readme follows the Contributor Covenant Code of Conduct.

License

MIT © OhhInk

ohhink/rrm 适用场景与选型建议

ohhink/rrm 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 124 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「security」 「laravel」 「permission」 「roles」 「permissions」 「rbac」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ohhink/rrm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ohhink/rrm 我们能提供哪些服务?
定制开发 / 二次开发

基于 ohhink/rrm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 124
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-06