fabiopaiva/zfc-user-crud

基于 Doctrine ORM 的 ZfcUser CRUD 接口。

1.0 2015-09-01 18:03 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:43:18 UTC


README

ZfcUserCrud 提供一个用于管理用户和角色的 CRUD 接口。需要 ZfcUserDoctrineOrm

安装

php composer.phar require fabiopaiva/zfc-user-crud:dev-master

用法

在 application.config.php 中启用此模块

<?php //
	return array(
			'modules' => array(
			'DoctrineModule',
			'DoctrineORMModule',
			'ZfcBase',
			'ZfcUser',
			'ZfcUserDoctrineORM',
			'ZfcUserCrud',
			// .. Another modules you use
			'Application'
			 ),
			...

不要忘记配置您的 Doctrine ORM,例如:doctrine.local.php

<?php
	return array(
	    'doctrine' => array(
	        'connection' => array(
	            'orm_default' => array(
	                'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
	                'params' => array(
            		    'host' => 'localhost',
	                    'port' => '3306',
            		    'user' => 'dbUser',
	                    'password' => 'dbPass',
	                    'dbname' => 'dbName',
	        )))));

创建表格

./vendor/bin/doctrine-module orm:schema-tool:update --dump-sql
#if it's ok, execute
./vendor/bin/doctrine-module orm:schema-tool:update --force

在您的视图中使用以下路由

<?php echo $this->url('zfc-user-crud');?> For user interface
<?php echo $this->url('zfc-user-crud-role');?> For role interface
    <?php echo $this->url('zfc-user-crud-password');?> For change user password

如果您想使用自己的实体,请覆盖配置

return array(
    'zfcusercrud' => array(
    	'userEntity' => 'ZfcUserCrud\Entity\User',
        'roleEntity' => 'ZfcUserCrud\Entity\Role'
    )

#ZfcAdmin

要使用 ZfcAdmin,只需像这样覆盖路由即可

<?php
return array(
    'router' => array(
        'routes' => array(
            'zfcadmin' => array(
                'child_routes' => array(
                    'zfc-user-crud' => array(
                        'type' => 'segment',
                        'options' => array(
                            'route' => '/users[/:action][/:id]',
                            'defaults' => array(
                                'controller' => 'ZfcUserCrud\Controller\Crud',
                                'action'     => 'index',
                            ),
                        ),
                    ),
                ),
            ),
            'zfc-user-crud' => array(
                'options' => array(
                    //if you change your ZfcAdmin url(admin), you must use your new url
                    'route' => '/admin/users[/:action][/:id]'
                )
            )
        ),
    )
);