appaydin/pd-user
Composer 安装命令:
composer require appaydin/pd-user
包简介
Symfony Simple User Bundle
README 文档
README
Simple user management system for Symfony 5+.
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require appaydin/pd-user
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
With Symfony 5, the package will be activated automatically. But if something goes wrong, you can install it manually.
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php file of your project:
<?php // config/bundles.php return [ //... Pd\UserBundle\PdUserBundle::class => ['all' => true] ];
Step 3: Create User, Group, Class
A) Create User Class
Create the User class for your application. This class can look and act however you want: add any properties or methods you find useful. This is your User class.
<?php // src/Entity/User.php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Pd\UserBundle\Model\User as BaseUser; /** * @ORM\Table(name="user") * @ORM\Entity * @UniqueEntity(fields="email", message="email_already_taken") */ class User extends BaseUser { public function __construct() { parent::__construct(); } }
B) Create Group Class
Create the Group class for your application. This class creates user groups.
<?php // src/Entity/Group.php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Pd\UserBundle\Model\Group as BaseGroup; /** * @ORM\Table(name="user_group") * @ORM\Entity * @UniqueEntity(fields="name", message="group_already_taken") */ class Group extends BaseGroup { }
Step 4: Settings Bundle
Create a "user.yaml" file for the settings.
# config/packages/user.yaml pd_user: user_class: App\Entity\User group_class: App\Entity\Group default_group: '' login_redirect: 'web_home' email_confirmation: true welcome_email: true user_registration: true #template_path: '@Admin/Auth' resetting_request_time: 7200 mail_sender_address: 'example@example.com' mail_sender_name: 'pdUser' active_language: ['en', 'tr'] register_type: '' resetting_type: ''
- user_class: Define 'User' class address
- group_class: Define 'Group' class address
- default_group: New members will join group id
- login_redirect: The router name to which logged-in users will be directed.
- email_confirmation: Enables email verification for register.
- welcome_email: Welcome new members welcome message.
- user_registration: Enable/Disable user registration.
- template_path: Directory for Twig templates. Changes can be made by copying the source directory.
- resetting_request_time: Enter the retry time in seconds for password renewal.
- mail_sender_address: Mail sender address
- mail_sender_name: Mail sender name
- active_language: List of Active Language
- register_type: Register Form Type
- resetting_type: Resetting Form Type
####Events UserEvent::REGISTER_BEFORE => It is launched before the registration form. UserEvent::REGISTER => When the recording is complete, it is launched. UserEvent::REGISTER_CONFIRM => E-mail is launched when registration is confirmed. UserEvent::RESETTING => The password is launched when the reset mail is sent. UserEvent::RESETTING_COMPLETE => It is launched when the password is changed.
Step 5: Configure Your Application's Security.yml
Below is a minimal example of the configuration necessary to use the pdUser in your application:
# config/packages/security.yaml security: enable_authenticator_manager: true password_hashers: App\Entity\User: algorithm: auto role_hierarchy: ROLE_ADMIN: [ROLE_USER] providers: pdadmin_auth: entity: class: App\Entity\User property: email firewalls: # Enable for Development dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: pattern: ^/ provider: pdadmin_auth lazy: true user_checker: Pd\UserBundle\Security\UserChecker switch_user: true http_basic: ~ entry_point: form_login form_login: use_referer: true login_path: security_login check_path: security_login #default_target_path: 'dashboard' # Login Redirect Path logout: path: security_logout #target: 'home' # Logout Redirect Path remember_me: secret: '%env(APP_SECRET)%' #lifetime: 604800 path: / access_control: - { path: ^/auth/login$, role: PUBLIC_ACCESS } - { path: ^/auth/register, role: PUBLIC_ACCESS } - { path: ^/auth/resetting, role: PUBLIC_ACCESS } #- { path: '^/', role: ROLE_ADMIN }
Step 6: Import pdUser Routing
Now that you have activated and configured the bundle, all that is left to do is import the pdUser routing files.
By importing the routing files you will have ready made pages for things such as logging in, register, password resetting.
#config/routes.yaml authorization: resource: "@PdUserBundle/Resources/config/routing.yaml" prefix: 'auth'
Step 6: Update Your Database Schema
All steps are completed. You can now update the database schema.
php bin/console doctrine:schema:update --force
appaydin/pd-user 适用场景与选型建议
appaydin/pd-user 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.61k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2018 年 10 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「account」 「user-management」 「symfony-user」 「pd-admin」 「pd-user」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 appaydin/pd-user 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 appaydin/pd-user 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 appaydin/pd-user 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Orchestra Platform Foundation
Symfony integration for Czech bank account library
A secure, modern user management system for PHP.
PHP IBAN - This library provides a converter for account number, bank code and IBAN.
UserBase PHP Client: Identity + Login + Signup Service
A module for Pluf to manage user profiles and user accounts
统计信息
- 总下载量: 17.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-29