symkit/routing-bundle
最新稳定版本:v0.0.5
Composer 安装命令:
composer require symkit/routing-bundle
包简介
Dynamic database-driven routing bundle
README 文档
README
Dynamic database-driven routing for Symfony. Manage routes in the database with native performance via Symfony's routing cache.
Requirements
- PHP 8.2+
- Symfony 7.0+ or 8.0+
doctrine/doctrine-bundle(Doctrine ORM)symkit/crud-bundle(for admin)symkit/sitemap-bundle(sitemap; disable viasymkit_routing.sitemap.enabledif not needed)symkit/search-bundle(global search; disable viasymkit_routing.search.enabledif not needed)
Installation
composer require symkit/routing-bundle
Register the bundle in config/bundles.php:
return [ // ... Symkit\RoutingBundle\RoutingBundle::class => ['all' => true], ];
Configuration
Example with all options (config/packages/symkit_routing.yaml):
symkit_routing: enabled: true entity_class: Symkit\RoutingBundle\Entity\Route # Your entity FQCN (must implement RouteEntityInterface) admin: enabled: true path_prefix: /admin/routes sitemap: enabled: true search: enabled: true listener: invalidate_sitemap_on_change: true
Loading database routes
In config/routes.yaml (or your main routes file):
database_routes: resource: . type: database
Admin routes
If admin.enabled is true, mount the bundle's admin routes with the configured prefix:
# config/routes.yaml _symkit_routing_admin: resource: '@SymkitRoutingBundle/config/routes.yaml' prefix: /admin/routes # or use %symkit_routing.admin.path_prefix% if you expose it as a parameter
Route names: admin_routes_list, admin_routes_edit.
Overriding the entity
- Create an entity implementing
Symkit\RoutingBundle\Contract\RouteEntityInterface(or extendSymkit\RoutingBundle\Entity\Route). - Map it with Doctrine (annotations/attributes or XML).
- Set
entity_classin config to your FQCN.
Your entity can add relations (e.g. a linked Page) and implement getLinkedPage() / getLinkedPageLabel() for sitemap and search behaviour.
Validation
The default entity uses:
ValidRouteSyntax: validates path and options (Symfony route pattern).UniqueEntity: uniquenameandpath.
Messages use the SymkitRoutingBundle translation domain (see translations/). For UniqueEntity, configure your validation mapping to use that domain if needed.
Cache
The bundle registers a RoutingDatabaseResource and a resource checker. The routing cache is invalidated only when the set of routes or their last update timestamp changes.
Sitemap and search
- Sitemap: when
sitemap.enabledis true, active routes (without parameters, GET allowed, not excluded) are exposed viaSymkitSitemapBundle(loader indexdatabase). - Search: when
search.enabledis true, routes are searchable in the global search (SymkitSearchBundle).
Contributing
- Run the quality pipeline:
make quality(cs-check, phpstan, deptrac, tests, infection). - Full CI:
make ci(adds security-check).
License
MIT.
统计信息
- 总下载量: 58
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-22