A new Symfony bundle for basic user management.
This package is part of the Message driven PHP project.
MsgPHP is a project that aims to provide (common) message based domain layers for your application. It has a low development time overhead and avoids being overly opinionated.
composer require msgphp/user-bundle
- Symfony 3.4 / 4.0 ready
- Doctrine persistence
- Symfony console commands
- Symfony security infrastructure
- Symfony validators
- Credential independent (supports e-mail, nickname, etc.)
- Multiple username / credential support
- Primary and secondary user e-mails
- Disabled / enabled users
- User roles
- User attribute values
- Adding user management to your Symfony application
- Commanding a decoupled User entity
- Decoupling the User entity with a new Symfony User Bundle
- Building a new Symfony User Bundle
<?php
// config/packages/msgphp_user.php
use MsgPhp\User\Entity\User;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return function (ContainerConfigurator $container) {
$container->extension('msgphp_user', [
'class_mapping' => [
User::class => \App\Entity\User\User::class,
],
]);
};
composer require annot form validator twig security simple-bus/symfony-bridge orm
composer require maker server --dev
bin/console make:user
And be done.
With DoctrineBundle
Repositories from MsgPhp\User\Infra\Doctrine\Repository\*
are registered as a service. Corresponding domain interfaces
from MsgPhp\User\Repository\*
are aliased.
Minimal configuration:
# config/packages/doctrine.yaml
doctrine:
orm:
mappings:
app:
dir: '%kernel.project_dir%/src/Entity'
type: annotation
prefix: App\Entity
- Requires
doctrine/orm
Command handlers from MsgPhp\User\Command\*
are registered as a service.
- Requires
DoctrineBundle + doctrine/orm
With SecurityBundle
Security infrastructure from MsgPhp\User\Infra\Security\*
is registered as a service.
In practice the security user is decoupled from your domain entity user. An approach described here.
MsgPhp\User\Infra\Security\SecurityUser
implementingSymfony\Component\Security\Core\User\UserInterface
App\Entity\User\User
extendingMsgPhp\User\Entity\User
Minimal configuration:
# config/packages/security.yaml
security:
encoders:
MsgPhp\User\Infra\Security\SecurityUser: bcrypt
providers:
msgphp_user: { id: MsgPhp\User\Infra\Security\SecurityUserProvider }
firewalls:
main:
provider: msgphp_user
anonymous: ~
- Requires
DoctrineBundle + doctrine/orm
- Suggests
SensioFrameworkExtraBundle
to enable the parameter converter
With symfony/console
Console commands from MsgPhp\User\Infra\Console\Command\*
are registered as a service.
- Requires
DoctrineBundle + doctrine/orm
- Requires
SimpleBusCommandBusBundle
With symfony/form
Form types from MsgPhp\User\Infra\Form\Type\*
are registered as a service.
With symfony/validator
Validators from MsgPhp\User\Infra\Validator\*
are registered as a service.
- Requires
DoctrineBundle + doctrine/orm
- Read the main documentation
- Browse the API documentation
- Try the Symfony demo application
- Get support on Symfony's Slack
#msgphp
channel or raise an issue
This repository is READ ONLY. Issues and pull requests should be submitted in the main development repository.