evilband7 / rbac-user-doctrine-orm
A module that integrate zfc-rbac with zfc-user
Requires
- php: ~7.0 || ~5.6
- doctrine/doctrine-module: ~1.0 || dev-master
- doctrine/doctrine-orm-module: ~1.0 || dev-master
- zendframework/zend-servicemanager: ~3.0 || ~2.7
- zf-commons/zfc-rbac: ~2.5 || dev-master
- zf-commons/zfc-user: ~1.0 || ~2.0 || 2.x-dev
Suggests
- zf-commons/zfc-user-doctrine-orm: RbacUserDoctrineOrm require ZfcUserDoctrineOrm but we didn't provide in depencency because it's not support ZF3 yet. btw you can install it manually.
This package is not auto-updated.
Last update: 2025-01-13 14:19:20 UTC
README
ZF Module which in integrate ZfcUserDoctrineOrm with ZfcRbac. Inspired by https://github.com/esserj/RbacUserDoctrineOrm
Dependencies
- PHP >= 5.6
- Zend Framework 3 or >= 2.7
- ZfcUser
- ZfcUserDoctrineOrm
- DoctrineModule
- DoctrineORMModule
- ZfcRbac
Installation
Install RbacUserDoctrineOrm Module using composer
{
...,
"require": {
...,
"evilband7/rbac-user-doctrine-orm" : "~0.1 || dev-master"
}
}
ps. If you using ZF2, please add zf-commons/zfc-user-doctrine-orm into your composer dependency. For ZF3, please install ZfcUserDoctrineOrm manually by cloning module into your project.
for ZF3 project, your composer should look like this.
{
...,
"require": {
...,
"zendframework/zend-mvc" : "~3.0",
"zendframework/zend-servicemanager" : "~3.0",
"zendframework/zend-eventmanager" : "~3.0",
"zendframework/zend-router" : "~3.0",
"zf-commons/zfc-rbac" : "~2.5 || dev-master",
"zf-commons/zfc-user" : "~2.0 || 2.x-dev",
"doctrine/doctrine-module" : "~1.0 || dev-master",
"doctrine/doctrine-orm-module" : "~1.0 || dev-master",
"evilband7/rbac-user-doctrine-orm" : "~0.1 || dev-master"
}
}
Then set up your Modules in config/application/application.config.php
, something like
'modules' => array(
'DoctrineModule',
'DoctrineORMModule',
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineORM',
'RbacUserDoctrineOrm',
'Application',
),
Now, you can use doctrine-module
to to set up your database tables (config your connection first Doctrine Connection Settings).
vendor/bin/doctrine-module orm:schema-tool:update --dump-sql
If SQL looks okay, do:
vendor/bin/doctrine-module orm:schema-tool:update --force
Roles
RbacUserDoctrineOrm provide 2 sources of roles.
-
dbRoles
field which is hierarchy roles. You can define dbRoles in database tables( auth_user, auth_role, auth_permission, auth_users_roles and auth_roles_permissions )
-
providerRoles
field which is comma separated inauth_user.provider_roles
column. Roles from this source will not work unless you provide your own RoleProvder
Customize User Entity
Fist, copy config/rbac-user-doctrine.global.php.dist to autoload folder. (don't forget to remove .dist) Then customize your entity class name
return [
'rbac-user-doctrine-orm' => [
'enable_default_user_entity' => false,
],
'zfcuser' => [
'userEntityClass' => 'YourUserEntityClass' //TODO
],
];
and your User class must extends RbacUserDoctrineOrm\Domain\AbstractRbacUser
TODO
- need more test on different version on depended module
- more documentation
- will release 0.x version soon.
Author
Mr. Siwapun Siwaporn map.siwapun@gmail.com
feel free to ask or suggest me. :)