larsvandersangen / project-template-bundle-dev
Reusable Symfony bundle with authentication, user management, and master data loading
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Type:symfony-bundle
pkg:composer/larsvandersangen/project-template-bundle-dev
Requires
- php: >=8.5
- ext-ctype: *
- ext-iconv: *
- doctrine/doctrine-bundle: ^3.2
- doctrine/doctrine-migrations-bundle: ^4.0
- doctrine/orm: ^3.6
- lexik/jwt-authentication-bundle: ^3.2
- symfony/cache: 7.4.*
- symfony/clock: 7.4.*
- symfony/config: 7.4.*
- symfony/console: 7.4.*
- symfony/dependency-injection: 7.4.*
- symfony/doctrine-bridge: 7.4.*
- symfony/error-handler: 7.4.*
- symfony/event-dispatcher: 7.4.*
- symfony/expression-language: 7.4.*
- symfony/filesystem: 7.4.*
- symfony/finder: 7.4.*
- symfony/framework-bundle: 7.4.*
- symfony/http-foundation: 7.4.*
- symfony/http-kernel: 7.4.*
- symfony/mailer: 7.4.*
- symfony/mime: 7.4.*
- symfony/options-resolver: 7.4.*
- symfony/password-hasher: 7.4.*
- symfony/process: 7.4.*
- symfony/property-access: 7.4.*
- symfony/property-info: 7.4.*
- symfony/routing: 7.4.*
- symfony/security-bundle: 7.4.*
- symfony/security-core: 7.4.*
- symfony/security-csrf: 7.4.*
- symfony/security-http: 7.4.*
- symfony/stopwatch: 7.4.*
- symfony/string: 7.4.*
- symfony/type-info: 7.4.*
- symfony/var-dumper: 7.4.*
- symfony/var-exporter: 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/flex: ^2
- symfony/http-client: 7.4.*
- symfony/phpunit-bridge: 7.4.*
- symfony/runtime: 7.4.*
This package is auto-updated.
Last update: 2026-02-20 21:26:11 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
- Fully Tested: 35 tests with 96 assertions (100% passing)
Installation
Via Composer (from Packagist)
composer require larsvandersangen/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 [ // ... LarsVanDerSangen\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:
project_template: resource: '@ProjectTemplateBundle/config/routes.yaml' prefix: /
4. Configure Security
Update config/packages/security.yaml:
security: password_hashers: LarsVanDerSangen\ProjectTemplateBundle\User\Entity\User: 'auto' providers: app_user_provider: entity: class: LarsVanDerSangen\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: - LarsVanDerSangen\ProjectTemplateBundle\Auth\Security\JwtAuthenticator entry_point: LarsVanDerSangen\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
php bin/console doctrine:migrations:migrate
8. Load Master Data
php bin/console app: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!"
}
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