nedwave / user-bundle
此包已被 废弃 并不再维护。未建议替代包。
用于Symfony2的用户管理。兼容Doctrine ORM
此包尚未发布任何版本,且信息较少。
README
Symfony2和Doctrine的用户管理
安装
使用composer安装包
"nedwave/user-bundle": "^3.0"
在AppKernel中注册bundle
new Nedwave\UserBundle\NedwaveUserBundle(),
从bundle扩展User实体
<?php namespace Acme\DemoBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; use Nedwave\UserBundle\Entity\User as BaseUser; /** * @ORM\Table(name="users") * @ORM\Entity() */ class User extends BaseUser { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * Get id * * @return integer */ public function getId() { return $this->id; } }
更新config.yml
# Nedwave User Bundle nedwave_user: user_class: Acme\DemoBundle\Entity\User firewall_name: main mailer: from_email: info@nedwave.com from_name: Nedwave registration: # Optional approval: false enabled: true
更新security.yml
security: encoders: Acme\DemoBundle\Entity\User: algorithm: bcrypt cost: 16 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: doctrine: id: nedwave_user.user_provider firewalls: main: pattern: ^/ anonymous: ~ context: application form_login: login_path: login check_path: login_check logout: path: logout target: / access_control: - { path: ^/%locale%/login, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/%locale%/password/reset, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/%locale%/password/request, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/%locale%/password/change, role: IS_AUTHENTICATED_FULLY }
更新routing.yml
nedwave_user: resource: "@NedwaveUserBundle/Resources/config/routing.yml" prefix: /