bprs/user-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bprs/user-bundle

Composer 安装命令:

composer require bprs/user-bundle

包简介

Simple Symfony Userbundle with RESTful API to share users between applications

README 文档

README

Simple, extendable Symfony Userbundle with RESTful API to share users between applications

installation

in your composer.json file, add to "require"

"require": {
    "bprs/user-bundle": "dev-master" 
}

(for stable versions, check out the latest release Tag!)

in your routing.yml, add

bprs_user:
    resource: .
    type: bprs_user

your security.yml needs to know how to use Bprs Users. Here is a simple example:

security:
    role_hierarchy:
        ROLE_ADMIN: ROLE_USER

    encoders:
        Bprs\UserBUndle\Entity\User:
            algorithm: bcrypt
            cost: 12

    providers:
        database:
            entity: 
                class: YouYourBundle:YourUser
                property: username

    firewalls:
        main:
            pattern:    /
            http_basic: ~
            form_login:
                login_path: bprs_user_login
                check_path: bprs_user_login_check
                default_target_path: intake_backend
                csrf_provider: form.csrf_provider
                default_target_path: /de
            logout: 
                path: bprs_user_logout
                target: /de
            anonymous: ~

    access_control:
        - { path: /backend, roles: ROLE_USER }
        - { path: /backend/admin, roles: ROLE_ADMIN}

finally, in your config.yml, add to doctrine:

doctrine:
    orm:
        resolve_target_entities:
            Bprs\UserBundle\Entity\BprsUserInterface: Your\YourBundle\Entity\YourUser
            
bprs_user:
    class: "YourBundle\Entity\YourUser"
    mail:
        commandline_host:   www.yourhost.com
        adress:             yourbot@example.com
        name:               yourbot
    permissions:
        - ROLE_BPRS_USER_BACKEND
        - ROLE_ADMIN
        - ROLE_USER
        # and whatever roles your application uses and a new created admin should have
    user_defaults:
        - ROLE_USER
        # and whatever roles a new created user should have

Usage

Extend the BprsUser Entity

The BprsUser Entity is a MappedSuperclass.

For example: Create your desired User Entity like this:

namespace You/YourBundle/Entity;

use Bprs/UserBundle/Entity/User as BprsUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * MyUser
 *
 * @ORM\Table()
 * @ORM\Entity
 */
class MyUser extends BprsUser
{
    /**
     * @var string
     * @ORM\Column(name="foo", type="string", length=3)
     */
    private $foo;
    
    /** and so on **/
}

And thats it. Doctrine will handle the rest and merge both entities into one table.

Create the first Admin user

# First (only 'needed' after a new installation or configuarion)
./app/console bprs:userbundle:warmup

./app/console bprs:userbundle:create_admin -1 yourname -2 your@email.com

The warmup commad adds all roles declared in the config 'permissions' to the database.
The create admin account will add a admin user with all permissions automatically added. Don't use that to create normal users if you don't want them to be able to access all parts of your application!

ROLES FOR THIS BUNDLE

ROLE_BPRS_USER_BACKEND -> Access to the UserController (CRUD)

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: 未知许可证
  • 更新时间: 2015-02-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固