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

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

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

effinix/user-permission-bundle

最新稳定版本:1.1.3

Composer 安装命令:

composer require effinix/user-permission-bundle

包简介

Reusable Symfony bundle for permission handling

README 文档

README

With one easy attribute, you can now protect controller methods and invokable controllers e.g:

src/Controller/Controller.php
<?php declare(strict_types=1);

namespace App\Controller;

use Effinix\UserPermissionBundle\Attribute\Attribute\Routing\RequirePermission;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;

#[AsController]
class Controller
{
    #[Route(
        name: 'public_website',
    )]
    #[RequirePermission('login')]
    public function index()
    {
        return new Response("Hello world!");
    }
}

Implement UserInterface to provide access to these routes

src/Entity/User.php
<?php declare(strict_types=1);

namespace App\Entity;

use Effinix\UserPermissionBundle\DependencyInversion\UserInterface;

class User implements UserInterface
{
    ...
    public function hasPermission(string $permission) : bool {
        // check if the permission is valid for this user
        return in_array($permission, $this->getPermissions());
    }
    
    /**
     * @return string[]
     */
    public function getPermissions() : array {
        // domain logic way of getting user permissions (e.g. storing in the database)
        return ['login'];
    }
}

Default config file:

effinix_user_permission:
  permission_store:
    provider:
    permissions:
      - login
  do_cache: true

when@dev:
  effinix_user_permission:
    do_cache: false
    logger: app.my-logger

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-12