vandersangen/project-template-bundle
Composer 安装命令:
composer require vandersangen/project-template-bundle
包简介
Reusable Symfony bundle with authentication, user management, and master data loading
README 文档
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
vandersangen/project-template-bundle 适用场景与选型建议
vandersangen/project-template-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.03k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「Authentication」 「bundle」 「jwt」 「master-data」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vandersangen/project-template-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vandersangen/project-template-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vandersangen/project-template-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
2lenet/EasyAdminPlusBundle
GraphQL authentication for your headless Craft CMS applications.
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
统计信息
- 总下载量: 1.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-22