connectholland/user-bundle
Symfony 4.4/5 user bundle providing registration and login forms, user creation command, email confirmation links, password recovery, optional OAuth (Google/GitHub/Facebook), and API accessibility. Optional JWT auth via Lexik bundle.
Since this is a Symfony bundle, Laravel developers would need to integrate it via Symfony’s ecosystem (e.g., via Laravel Symfony Bridge or a Symfony microkernel). Below are the first steps to leverage it in a Laravel-like workflow:
Install the Bundle Add the bundle to your Symfony/Laravel project (if using Symfony components):
composer require connectholland/user-bundle
Enable the Bundle
Register the bundle in config/bundles.php (Symfony) or adapt for Laravel:
// config/bundles.php
return [
// ...
ConnectHolland\UserBundle\ConnectHollandUserBundle::class => ['all' => true],
];
Configure Environment Variables
Set up email and OAuth (if needed) in .env:
[email protected]
# OAuth example (Google)
USERBUNDLE_OAUTH_GOOGLE_ID=your-client-id.apps.googleusercontent.com
USERBUNDLE_OAUTH_GOOGLE_SECRET=your-client-secret
Run Database Migrations
The bundle includes a User entity. Run migrations:
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
First Use Case: CLI User Creation Create a user via command line (useful for seeding or admin tasks):
php bin/console connectholland:user:create [email protected] P@ssw0rd --role=ROLE_USER
Enable Routing
Import the bundle’s routes in config/routes.yaml:
connectholland_user:
resource: '@ConnectHollandUserBundle/Resources/config/routing.yaml'
Test the Login/Registration Flow
/register (or /inloggen for Dutch localization)./password-reset.@ConnectHollandUser/registration.html.twig) or override them in your theme.POST to /api/register with:
{
"email": "[email protected]",
"password": "P@ssw0rd",
"plainPassword": "P@ssw0rd" // Required for API
}
Response: Returns a 200 status (no body) with the user activated.hwi/oauth-bundle:
composer require hwi/oauth-bundle
.env (e.g., USERBUNDLE_OAUTH_GOOGLE_ID).config/routes.yaml:
connectholland_user_oauth:
resource: '@ConnectHollandUserBundle/Resources/config/routing_oauth.yaml'
/connect/google (or /connect/facebook).lexik/jwt-authentication-bundle and api-platform/core:
composer require lexik/jwt-authentication-bundle api
private.pem, public.pem) and set in .env:
JWT_SECRET_KEY=config/jwt/private.pem
JWT_PUBLIC_KEY=config/jwt/public.pem
POST /api/users/authenticate:
{
"email": "[email protected]",
"password": "P@ssw0rd"
}
/password-reset.POST /api/password-reset with:
{
"email": "[email protected]"
}
Response: 200 status (no body). User clicks the link and submits a new password.php bin/console connectholland:user:create [email protected] AdminP@ss --role=ROLE_ADMIN
/api/account/details (requires authentication).Request, Response) in controllers.templates/ConnectHollandUser/ to customize views.UserManager).cp vendor/connectholland/user-bundle/src/Entity/User.php src/Entity/
// src/Entity/User.php
/**
* @ORM\Column(type="string", nullable=true)
*/
private $customField;
php bin/console make:migration
php bin/console doctrine:migrations:migrate
config/packages/connectholland_user.yaml, set:
user_entity: App\Entity\User
vendor/connectholland/user-bundle/templates/ to templates/ConnectHollandUser/.{# templates/ConnectHollandUser/registration.html.twig #}
{% extends '@ConnectHollandUser/registration.html.twig' %}
{% block title %}Custom Registration{% endblock %}
@Assert\Email).ApiPlatform\Metadata\Operation with pagination.security.yaml:
access_control:
- { path: ^/api, roles: ROLE_USER, methods: [GET, POST, PUT, DELETE] }
API Response Quirks:
OAuth Configuration:
routing_oauth.yaml) will break /connect/google links.resource_owners in security.yaml matches your provider names (e.g., google: connectholland_user_oauth_check_main_google).Email Delivery:
USERBUNDLE_FROM_EMAILADDRESS and Symfony’s mailer config (framework/mailer).symfony/mailer with a real transport (e.g., SMTP) in production:
# config/packages/mailer.yaml
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
User Entity Overrides:
User, ensure your entity is properly mapped in orm/EntityManager to avoid proxy conflicts.User, run make:migration to avoid schema mismatches.JWT Token Handling:
JWT_SECRET_KEY and `JWT_PHow can I help you explore Laravel packages today?