app-verk/user-bundle
Composer 安装命令:
composer require app-verk/user-bundle
包简介
Appverk user bundle
关键字:
README 文档
README
Simple and lightweight User bundle for Symfony 3 projects. Provides user and role functionalities with ACL support.
Old version:
If u need help with 1.* branch, visit v1.x documentation.
Installation:
Required the bundle with composer:
$ php composer.phar require app-verk/user-bundle
Configuration
Register the bundle in your AppKernel.php
// ./app/AppKernel.php
public function registerBundles()
{
$bundles = [
...
new AppVerk\UserBundle\UserBundle(),
...
];
}
Add a new config file, for example user.yml
#./app/config/user.yml
user:
entities:
user_class: #E.g. AppBundle\Entity\User
acl:
enabled: #true|false defines to use or not to use ACL
access_denied_path: #route bame where user should be redirect when he dont have privileges to action
Import user.yml file to config.yml
imports:
...
- { resource: user.yml }
Next create two entities in your bundle (E.g. AppBundle\Entity):
- User
<?php
namespace AppBundle\Entity;
use AppVerk\UserBundle\Entity\User as AbstractUser;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
*/
class User extends AbstractUser implements EntityInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
}
You can use configuration format which you prefer (yml, xml, php or annotation)
Run
php bin/console doctrine:schema:update --force
Now You can create admin user with command line:
php bin/console user:create:admin <username> <email> <password>
ACL
Enable ACL
#./app/config/user.yml
user:
acl
enabled: true
access_denied_path: #route name
Use annotation to define protected action
// ./src/AppBundle/Controller/DefaultController.php ... use AppVerk\UserBundle\Annotation\AVSecurity; ... /** * ... * @AVSecurity(allow={"ROLE_ADMIN"}, disallow={"ROLE_X"}, name="list", group="default") */ public function listAction() { return $this->render('@App/controller/user/list.html.twig'); }
Custom AccessResolver
In some cases u need to create your own logic to decide about access to action. In that case u just need to create custom accessResolver and put your logic
// ./src/AppBundle/Security/CustomAccessResolver.php ... use AppVerk\UserBundle\Security\AccessResolverInterface; ... class SimpleAccessResolver implements AccessResolverInterface { public function resolve(RoleableInterface $user, $action): bool { // your own logic } }
Insert new resolver to configuration file:
#./app/config/user.yml
user:
entities:
user_class: #E.g. AppBundle\Entity\User
acl:
enabled: #true|false defines to use or not to use ACL
access_denied_path: #route bame where user should be redirect when he dont have privileges to action
access_resolver_class: AppBundle\Security\CustomAccessResolver
app-verk/user-bundle 适用场景与选型建议
app-verk/user-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.79k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「acl」 「user bundle」 「role」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 app-verk/user-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 app-verk/user-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 app-verk/user-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Multiauth package
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
This package provides a flexible way to add Role-based Permissions to Laravel 6.x
统计信息
- 总下载量: 11.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-25