vandersangen / project-template-bundle
Reusable Symfony bundle with authentication, user management, and master data loading
Package info
github.com/vandersangen/project-template-bundle
Type:symfony-bundle
pkg:composer/vandersangen/project-template-bundle
Requires
- php: >=8.5
- ext-ctype: *
- ext-iconv: *
- doctrine/doctrine-bundle: ^3.2
- doctrine/doctrine-migrations-bundle: ^4.0
- doctrine/orm: ^3.6
- dragonmantank/cron-expression: ^3.3
- lexik/jwt-authentication-bundle: ^3.2
- symfony/config: 7.4.*
- symfony/console: 7.4.*
- symfony/dependency-injection: 7.4.*
- symfony/doctrine-bridge: 7.4.*
- symfony/event-dispatcher: 7.4.*
- symfony/filesystem: 7.4.*
- symfony/finder: 7.4.*
- symfony/form: 7.4.*
- symfony/framework-bundle: 7.4.*
- symfony/http-foundation: 7.4.*
- symfony/http-kernel: 7.4.*
- symfony/mailer: 7.4.*
- symfony/messenger: 7.4.*
- symfony/mime: 7.4.*
- symfony/password-hasher: 7.4.*
- symfony/process: 7.4.*
- symfony/routing: 7.4.*
- symfony/security-bundle: 7.4.*
- symfony/security-core: 7.4.*
- symfony/security-http: 7.4.*
- symfony/string: 7.4.*
- symfony/twig-bundle: 7.4.*
- symfony/yaml: 7.4.*
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: ^4.3
- nelmio/cors-bundle: ^2.6
- phpmd/phpmd: ^2.15
- phpro/grumphp: ^2.10
- phpunit/phpunit: ^11.5
- rector/rector: ^2.0
- slevomat/coding-standard: ^8.22
- squizlabs/php_codesniffer: ^3.11
- symfony/browser-kit: 7.4.*
- symfony/css-selector: 7.4.*
- symfony/dotenv: 7.4.*
- symfony/http-client: 7.4.*
- symfony/phpunit-bridge: 7.4.*
- symfony/runtime: 7.4.*
This package is auto-updated.
Last update: 2026-03-04 19:59:16 UTC
README
A reusable Symfony bundle providing authentication, user management, and master data loading functionality.
Features
- JWT Authentication: Complete authentication system with login, register, password reset
- User Management: User entity, repository, and service layer
- Master Data Loading: Flexible master data loading from PHP configuration files
- Database Tools: Git branch-based database naming, database copy command
- Health Checks: API health check endpoints
- Queue (Messenger): Async message handling,
QueueJobLogfor monitoring, failed jobs in a separate transport - SuperAdmin: Eigen login en gebruikers; alleen SuperAdmin-users hebben toegang. Zie docs/super-admin.md
- Cron: Scheduler command; cron-beheer (API en web UI) zit in de SuperAdmin-module. Zie docs/cron-module.md
- Fully Tested: 35 tests with 96 assertions (100% passing)
Installation
Via Composer (from Packagist)
composer require vanDerSangen/project-template-bundle
Requirements
- PHP >= 8.5
- Symfony >= 7.4
- Doctrine ORM >= 3.6
- Lexik JWT Authentication Bundle >= 3.2
Quick Start
1. Register the Bundle
Add to config/bundles.php:
return [ // ... VanDerSangen\ProjectTemplateBundle\ProjectTemplateBundle::class => ['all' => true], ];
2. Configure the Bundle
Create config/packages/project_template.yaml:
project_template: mailer_sender: 'noreply@example.com'
3. Import Routes
Add to config/routes.yaml (path relative to your config/ directory):
project_template: resource: '../vendor/vandersangen/project-template-bundle/config/routes.yaml' type: yaml prefix: /
With a path repository use e.g. ../project-template-bundle/config/routes.yaml. Then run php bin/console cache:clear and php bin/console debug:router to verify.
4. Configure Security
Update config/packages/security.yaml:
security: password_hashers: VanDerSangen\ProjectTemplateBundle\User\Entity\User: 'auto' providers: app_user_provider: entity: class: VanDerSangen\ProjectTemplateBundle\User\Entity\User property: email firewalls: public: pattern: ^/(api/health|api/auth/(login|register|forgot-password|reset-password)) security: false api: pattern: ^/api stateless: true provider: app_user_provider custom_authenticators: - VanDerSangen\ProjectTemplateBundle\Auth\Security\JwtAuthenticator entry_point: VanDerSangen\ProjectTemplateBundle\Auth\Security\JwtAuthenticator access_control: - { path: ^/api/health, roles: PUBLIC_ACCESS } - { path: ^/api/auth/(login|register|forgot-password|reset-password), roles: PUBLIC_ACCESS } - { path: ^/api, roles: ROLE_USER }
5. Generate JWT Keys
mkdir -p config/jwt openssl genrsa -out config/jwt/private.pem -aes256 -passout pass:changeme 4096 openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem -passin pass:changeme
6. Configure JWT
Create config/packages/lexik_jwt_authentication.yaml:
lexik_jwt_authentication: secret_key: '%kernel.project_dir%/config/jwt/private.pem' public_key: '%kernel.project_dir%/config/jwt/public.pem' pass_phrase: 'changeme'
7. Run Migrations
The bundle automatically registers its migrations in your application. When you run the migrations command, both your application's migrations and the bundle's migrations will be executed:
php bin/console doctrine:migrations:migrate
The bundle's migrations are registered under the DoctrineMigrations\ProjectTemplateBundle namespace and will create the required tables (users, mails, queue_job_logs).
8. Load Master Data
php bin/console bundle:master-data:load
Usage
Authentication Endpoints
The bundle provides the following authentication endpoints:
Register
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "SecurePass123!",
"firstName": "John",
"lastName": "Doe"
}
Login
POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "SecurePass123!"
}
Response:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
"user": {
"id": 1,
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
}
}
Forgot Password
POST /api/auth/forgot-password
Content-Type: application/json
{
"email": "user@example.com"
}
Reset Password
POST /api/auth/reset-password
Content-Type: application/json
{
"token": "reset-token-from-email",
"password": "NewSecurePass123!"
}
Queue and failed jobs
The bundle registers a failed Messenger transport. Jobs that fail after all retries are moved there. To list or retry them:
php bin/console messenger:failed:show failed php bin/console bundle:queue:retry-failed --force
See docs/messenger-failed-jobs.md for details and cron examples.
Protected Endpoints
Use the JWT token in the Authorization header:
GET /api/users/1 Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...
License
MIT
Support
- Issues: GitHub Issues
- Source: GitHub Repository