定制 symkit/routing-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

symkit/routing-bundle

最新稳定版本:v0.0.5

Composer 安装命令:

composer require symkit/routing-bundle

包简介

Dynamic database-driven routing bundle

README 文档

README

CI Latest Version PHPStan Level 9

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 via symkit_routing.sitemap.enabled if not needed)
  • symkit/search-bundle (global search; disable via symkit_routing.search.enabled if 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

  1. Create an entity implementing Symkit\RoutingBundle\Contract\RouteEntityInterface (or extend Symkit\RoutingBundle\Entity\Route).
  2. Map it with Doctrine (annotations/attributes or XML).
  3. Set entity_class in 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: unique name and path.

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.enabled is true, active routes (without parameters, GET allowed, not excluded) are exposed via SymkitSitemapBundle (loader index database).
  • Search: when search.enabled is 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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固