symkit / routing-bundle
Dynamic database-driven routing bundle
Installs: 58
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/symkit/routing-bundle
Requires
- php: >=8.2
- doctrine/doctrine-bundle: ^2.0 || ^3.0
- symfony/framework-bundle: ^7.0 || ^8.0
- symkit/crud-bundle: ~0.0.1
- symkit/form-bundle: ~0.0.1
- symkit/menu-bundle: ~0.0.1
- symkit/metadata-bundle: ~0.0.1
- symkit/search-bundle: ~0.0.1
- symkit/sitemap-bundle: ~0.0.1
Requires (Dev)
- deptrac/deptrac: ^2.0
- friendsofphp/php-cs-fixer: ^3.0
- infection/infection: ^0.29
- phpro/grumphp: ^2.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.0 || ^11.0
- symkit/bundle-ai-kit: ~0.0.1
Suggests
- symkit/search-bundle: For global search integration (searchable routes)
- symkit/sitemap-bundle: For sitemap integration (expose routes in sitemap)
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.